Access iframe DOM

Y

Yansky

Is it possible to read the DOM of an iframe if the iframe's src is
from another domain?

I realise I can't manipulate the DOM from another domain for security
reasons, but can I access the DOM and just read object's values?

This is what I've tried so far without any success:

document.getElementsByTagName("iframe").contentWindow;
document.getElementsByTagName("iframe").innerHTML;
document.getElementsByTagName("iframe").childNodes[0].innerHTML;
document.getElementsByTagName("iframe").childNodes[0].nodeValue;
document.getElementsByTagName("iframe").documentElement;
document.getElementsByTagName("iframe").contentDocument.
document.getElementById("testIframe").innerHTML;
document.getElementById("testIframe").childNodes[0].innerHTML;
document.getElementById("testIframe").childNodes[0].nodeValue;
 
M

Mayank

Is it possible to read the DOM of an iframe if the iframe's src is
from another domain?

I realise I can't manipulate the DOM from another domain for security
reasons, but can I access the DOM and just read object's values?

This is what I've tried so far without any success:

document.getElementsByTagName("iframe").contentWindow;
document.getElementsByTagName("iframe").innerHTML;
document.getElementsByTagName("iframe").childNodes[0].innerHTML;
document.getElementsByTagName("iframe").childNodes[0].nodeValue;
document.getElementsByTagName("iframe").documentElement;
document.getElementsByTagName("iframe").contentDocument.
document.getElementById("testIframe").innerHTML;
document.getElementById("testIframe").childNodes[0].innerHTML;
document.getElementById("testIframe").childNodes[0].nodeValue;


Saw this someplace
http://xkr.us/articles/dom/iframe-document/
See if this works for you
 
L

-Lost

Mayank said:
Is it possible to read the DOM of an iframe if the iframe's src is
from another domain?

I realise I can't manipulate the DOM from another domain for security
reasons, but can I access the DOM and just read object's values?

This is what I've tried so far without any success:

document.getElementsByTagName("iframe").contentWindow;
document.getElementsByTagName("iframe").innerHTML;
document.getElementsByTagName("iframe").childNodes[0].innerHTML;
document.getElementsByTagName("iframe").childNodes[0].nodeValue;
document.getElementsByTagName("iframe").documentElement;
document.getElementsByTagName("iframe").contentDocument.
document.getElementById("testIframe").innerHTML;
document.getElementById("testIframe").childNodes[0].innerHTML;
document.getElementById("testIframe").childNodes[0].nodeValue;


Saw this someplace
http://xkr.us/articles/dom/iframe-document/
See if this works for you

Along similar lines:

http://groups.google.com/group/comp...st&q=io.contentwindow&rnum=1#997f310ccaca0c8d
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top