iframe problem using javascript

Posted by Arjun Singh on Stack Overflow See other posts from Stack Overflow or by Arjun Singh
Published on 2010-01-28T04:50:59Z Indexed on 2010/04/30 0:07 UTC
Read the original article Hit count: 167

Filed under:
|
|
|

Does anyone know how to get the HTML out of an IFRAME? I have tried several different ways:

document.getElementById('iframe01').contentDocument.body.innerHTML, document.frames['iframe01'].document.body.innerHTML, document.getElementById('iframe01').contentWindow.document.body.innerHTML, etc

but none of them worked.

I believe the reason they're not working is that the content of my iframe doesn't have a body tag (I'm loading XML). Any other way to get all the contents of the iframe? I am open to jQuery too.

This:

document.getElementById('iframe01').contentWindow.document.body.innerHTML

works fine in the IE, but this:

document.getElementById('iframe01').contentDocument.body.innerHTML

does not work for FF.

© Stack Overflow or respective owner

Related posts about iframe

Related posts about JavaScript