I have an iframe that looks like this:
<iframe id="iframe2" ...>
#document
<html>...</html>
</iframe>
I am trying to get the item underneath the iframe with the html tag.
In JavaScript, when I do:
document.getElementByID("iframe2")
this returns the correct iframe.
However, when I do this:
document.getElementByID("iframe2").childNodes
the return value is [].
document.getElementByID("iframe2").getElementsByTagName("#document") and document.getElementByID("iframe2").getElementsByTagName("html") also return [].
How do I access that html tag?
Also, what is that #document tag called?
Or, the variant not supported by older IE,
This will get you the
documentobject of the embedded page, and from there you can use.documentElement,.bodyor.headproperties to get the html/body/head DOM.If you want the
windowobject of the embedded page, usecontentWindowinstead ofcontentDocument.MDN has a guide to iframe scripting that you will probably find helpful.