我该如何在Chrome中调用以下内容?
iframe.contentWindow.document
iframe.contentWindow.document
iframe.contentWindow.document
,但是有一个小问题你可能会遇到:如果设置给iframe.src
属性的文件是本地访问(即使用"file://"协议),那么该属性在Chrome中将不可访问。如果您指定了相对地址并尝试在没有使用像IIS或Apache这样的Web服务器的情况下测试脚本(通过双击它),就会发生这种情况。同样适用于iframe.contentDocument
。iframe.contentDocument
是你想要的。
.defaultView.getComputedStyle
时,针对 iframe.contentDocument
会报错 Uncaught TypeError: Cannot call method 'getComputedStyle' of undefined
? - SkizitcontentDocument
,则最好使用它。 - Tim Down<iframe id="popupFrame" />
<script type="text/javascript">
var popupFrame = document.getElementById('popupFrame');
var iFrameDoc;
if (switchAccountsPopupFrame.document) {
iFrameDoc = switchAccountsPopupFrame.document; // works with IE9 and FF9
}
else {
// Google Chrome (16.0.912.75 m)
iFrameDoc = switchAccountsPopupFrame.ownerDocument;
}
....
</script>