Aug
22
Wed
22
Retrieve content of iFrame
I’ve just figured out the correct DOM to retrieve the HTML out of an iFrame. Works on IE 6+7, Firefox 2, and Safari 3.0.2. Not that any of my users use anything other than IE.
- var x=document.getElementById(“frm”);
- alert(x.contentWindow.document.documentElement.innerHTML);
I used Firebug (add-on to Firefox) to trace the DOM to find the necessary hierarchy. “outerHTML” doesn’t seem to work, but that is ok as all that is missing is the “html” tags.


Sightings