问题描述
我一直在试图开发一个浏览器扩展,它需要将事件处理程序注入到页面上的所有iFrame中。我发现一些iFrames与用于Disqus评论系统的iFrames有内容但没有contentDocument。
这是如何实现的,以及如何访问不带contentDocument的iframe的事件处理程序?
查看页面底部的注释部分,查看示例。如果您检查注释文本区域,则会看到它位于没有contentDocument的iFrame中。 nofollow>同源政策
I've been trying to develop a browser extension that needs to inject event handlers into all iFrames on a page. I have found that some iFrames, like those used for the Disqus commenting system, have content but no contentDocument.
How is this possible, and how can I access the event handlers for an iframe without a contentDocument?
Check out the comment section at the bottom of this page for an example. If you inspect the comment text area, you will see it is in an iFrame that has no contentDocument.
This is caused by Same-Origin policy
这篇关于具有内容的iFrame如何具有未定义的contentDocument对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!