“ iframe.contentDocument” Not Working in IE8 and FF(3.5 and below) any other steps to solve this?

最后都变了- 提交于 2019-11-28 03:12:34

问题


I used this "iframe.contentDocument" in js file-uploader , But it not working in IE8 ,Firefox(3.5 and below versions. How can i solve this by using other DOM's for working with iframe ?

Thanks to all


回答1:


Try

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);
}


来源:https://stackoverflow.com/questions/4310946/iframe-contentdocument-not-working-in-ie8-and-ff3-5-and-below-any-other-ste

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!