iframe.contentWindow.document Chrome的替代? [英] iframe.contentWindow.document Chrome alternative?
问题描述
我如何在Chrome中调用以下内容? iframe.contentWindow.document
How would I call the following in Chrome? iframe.contentWindow.document
推荐答案
c $ c> iframe.contentWindow.document ,但是您可能会陷入一些折磨:如果文件设置为 iframe.src
属性正在本地访问(即使用file://协议),该属性在Chrome中无法访问。如果您指定相对文件地址并尝试在不使用IIS或Apache等Web服务器的情况下(通过简单地双击它)来测试脚本,就会发生这种情况。这同样适用于 iframe.contentDocument
。
Chrome does in fact support iframe.contentWindow.document
, but there's a little wrinkle that you've probably fallen prey to: if the file set to the iframe.src
property is being accessed locally (i.e. using the "file://" protocol), that property is inaccessible in Chrome. This will happen if you specify a relative file address and attempt to test the script without using a web-server like IIS or Apache (by simply double-clicking it). The same also applies to iframe.contentDocument
.
我碰到过类似的问题, Chrome不会接受动态附加到iframe的事件处理程序。然后我在这篇文章中发现了这个注释,并且用Apache进行了测试,嘿,它突然开始工作了。
I ran into a similar problem where, for some odd reason, Chrome would not accept event handlers dynamically attached to iframes. Then I found the note in this article, tested with Apache, and hey presto, it suddenly began to work.
这篇关于iframe.contentWindow.document Chrome的替代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!