How to run this on IE8?
var innerdoc = document.getElementsByTagName('iframe')[2].contentDocument;
I can't use jQuery neither getElementsById()
.
How to run this on IE8?
var innerdoc = document.getElementsByTagName('iframe')[2].contentDocument;
I can't use jQuery neither getElementsById()
.
According to MDN, the contentDocument
property is not supported in IE8.
To work around that, you could access .contentWindow.document
instead:
var element = document.getElementsByTagName('iframe')[2],
innerDoc = null;
if (element.contentDocument) {
innerDoc = element.contentDocument;
}
else if (element.contentWindow) { // IE fallback
innerDoc = element.contentWindow.document;
}