admin管理员组文章数量:1287577
I've got the following code which works fine in Firefox...
if (!iFrame) iFrame = outerDoc.getElementById('_dialog_iframe');
var iFrameDoc = iFrame.contentWindow.document; // get iframe doc
and the Chrome version...
if (!iFrame) iFrame = outerDoc.getElementById('_dialog_iframe');
var iFrameDoc = iFrame.document; // get iframe doc
I'm testing the code be getting iFrameDoc.body
when I run the FireFox code in Firefox it works fine. However, the Chrome code returns undefined
. Why? How do I fix this so that it'll work fine in Chrome?
I've got the following code which works fine in Firefox...
if (!iFrame) iFrame = outerDoc.getElementById('_dialog_iframe');
var iFrameDoc = iFrame.contentWindow.document; // get iframe doc
and the Chrome version...
if (!iFrame) iFrame = outerDoc.getElementById('_dialog_iframe');
var iFrameDoc = iFrame.document; // get iframe doc
I'm testing the code be getting iFrameDoc.body
when I run the FireFox code in Firefox it works fine. However, the Chrome code returns undefined
. Why? How do I fix this so that it'll work fine in Chrome?
1 Answer
Reset to default 11If the iframe element has a document
property in Chrome then I'm surprised, and it's non-standard and not supported in other browsers. The standards-based property is contentDocument
, and to support other browsers you can use contentWindow.document
. The following will work in all major browsers:
var iFrameDoc = iFrame.contentDocument || iFrame.contentWindow.document;
本文标签: javascriptChrome Getting iFrame and inserting into bodyStack Overflow
版权声明:本文标题:javascript - Chrome: Getting iFrame and inserting into body - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741307917a2371479.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论