“ iframe.contentDocument”在IE8和FF(3.5及以下)中不起作用的其他步骤可以解决此问题吗?

StackOverflow https://stackoverflow.com/questions/4310946

我在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);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top