Ski*_*zit 3 javascript iframe google-chrome google-chrome-extension
我有以下代码在Firefox中正常工作...
if (!iFrame) iFrame = outerDoc.getElementById('_dialog_iframe');
var iFrameDoc = iFrame.contentWindow.document; // get iframe doc
Run Code Online (Sandbox Code Playgroud)
和Chrome版本......
if (!iFrame) iFrame = outerDoc.getElementById('_dialog_iframe');
var iFrameDoc = iFrame.document; // get iframe doc
Run Code Online (Sandbox Code Playgroud)
我正在测试代码,iFrameDoc.body
当我在Firefox中运行FireFox代码时,它运行正常.但是,Chrome代码会返回undefined
.为什么?如何解决这个问题,以便它在Chrome中运行良好?
Tim*_*own 11
如果iframe元素document
在Chrome中具有属性,那么我会感到惊讶,并且它是非标准的,并且在其他浏览器中不受支持.基于标准的属性是contentDocument
,并支持您可以使用的其他浏览器contentWindow.document
.以下内容适用于所有主流浏览器:
var iFrameDoc = iFrame.contentDocument || iFrame.contentWindow.document;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6916 次 |
最近记录: |