Click to See Complete Forum and Search --> : DOM of an iframe


chuvak
07-28-2003, 01:14 PM
Hi,

I got an iframe on my page and I would like to change some content inside that iframe dynamically.
How can I get the DOM tree of that frame?
I tried something like this:
...
<iframe id="ifr" src="..." ...>
</iframe>
...

document.getElementById("ifr").contentDocument.getElementById(<some id from that document>)...

This doesn't work however. Is the syntax wrong?

thanks in advance

Khalid Ali
07-28-2003, 03:03 PM
This will work

parent.frameName.document.getElementById....

however,if the page opened in the ifram is an out of domain page then it will not work because of the browser security model

chuvak
07-28-2003, 05:07 PM
Unfortunately that doesn't work for me.

Mozilla gives error
...frameName.document has no properties

if I use ...frameName.contentDocument then it doesn't give that error but now ...frameName.contentDocument.getElementById(...) has no properties