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
Having something like the following would work.
You can use the contentDocument or contentWindow property for that purpose. Here is the sample code.
here, my frame is the id of your iframe. Note: You can't extract the content out of an iframe from a src outside you domain.
Conroy's answer was right. In the case you need only stuff from body tag, just use:
You can get html out of an iframe using this code iframe = document.getElementById('frame'); innerHtml = iframe.contentDocument.documentElement.innerHTML
I think this is what you want:
EDIT:
I have it on good authority that this won't work in Chrome and Firefox although it works perfectly in IE, which is where I tested it. In retrospect, that was a big mistake
This will work:
I understand that this isn't exactly what was asked but don't want to delete the answer because I think it has a place.
I like @ravz's jquery answer below.