Forum Moderators: open

Message Too Old, No Replies

nested div tag not working

         

amitw29

2:50 am on Oct 16, 2006 (gmt 0)

10+ Year Member



hi I have a problem with nested div tags, folling is the code.

<html>
<head>
<script>
function open()
{
document.getElementById('middle').innerHTML='<object type="text/html" data="jsp/client/administration.htm" width="600" height="500"></object>';

}
</script>
</head>
<body>
<div id='top'><a href="#" onClick="open()">open</a></div>
<div id='middle'></div>
<div id='foot'></div>
</body></html>


now the problem is i am opening a html file in middle div tag using object reference in java script.
But inside administration.html i have another link which change the content of div with foot id.
And i gets element 'foot' is undefined. It seems like the page in inner div tag cannot access the other elements in parent page.
Please help me out.
thanks in advance.

kaled

10:41 am on Oct 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the javascript runs immediately (i.e. before the page has fully loaded) then the foot div does not yet exist.

Perhaps you should assign the document.body.onload event and use that to call the necessary code when the page has completed loading.

Kaled.

kaled

12:07 pm on Oct 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Disregard the above... I didn't read the example code properly.

It may not be relevant, but it is a bad idea to call a function open() since there are already two open() functions (belonging to the window and document objects).

Kaled.

whoisgregg

3:39 pm on Oct 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It seems like the page in inner div tag cannot access the other elements in parent page.

It looks like you don't have any cross-domain issues, since "jsp/client/administration.html" is on the same site... How are you referencing the <div id="foot"> from the other file?

P.S. I've not seen the <object> tag used in this way, but I'll assume it's behavior is identical to an <iframe>. :/