"iframe.contentDocument"在IE8和FF(3.5及以下版本)中无法解决此问题的任何其他步骤?

aja*_*jay 9 javascript iframe denied uploader

我在js file-uploader中使用了这个"iframe.contentDocument",但它不适用于IE8,Firefox(3.5及以下版本.如何通过使用其他DOM来处理iframe来解决这个问题?

谢谢大家

mpl*_*jan 11

尝试

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);
}
Run Code Online (Sandbox Code Playgroud)