“ iframe.contentDocument”在IE8和FF(3.5及以下)中不起作用的其他步骤可以解决此问题吗?
-
29-09-2019 - |
题
我在js file-uploader中使用了此“ iframe.contentDocument”,但是它在IE8,Firefox(3.5及以下版本)中不起作用。如何通过使用其他DOM来与IFRAME一起解决此问题?
谢谢大家
解决方案
尝试
var doc;
var iframeObject = document.getElementById('iframeID'); // MUST have an ID
if (iframeObject.contentDocument) { // DOM
doc = iframeObject.contentDocument;
}
else if (iframeObject.contentWindow) { // IE win
doc = iframeObject.contentWindow.document;
}
if (doc) {
var something = doc.getElementById('someId');
}
else {
alert('Wonder what browser this is...'+navigator.userAgent);
}
不隶属于 StackOverflow