将鼠标事件从 iframe 传播到托管文档
我有一个覆盖整个 HTML 文档的 iframe,我想将点击和悬停事件传播回托管文档。
我有什么选择?
I have an iframe covering the entire HTML document, and I'd like to propagate clicks and hover events back to the hosting document.
What are my options?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
几周前,我被要求针对一个项目对此进行研究。这是可以做到的,这里有一个实际的工作示例:
http://www.esqsoft .com/javascript_examples/iframe_talks_to_parent/
但是,要记住的关键一点是,除非父级和子级位于同一域,否则不可能发生事件在他们之间传递。我认为,如果您的 iframe 包含来自不同域的页面,那么您就不走运了。
I was asked to look into this several weeks ago for a project. It's possible to do it, and there's a working example of it in action here:
http://www.esqsoft.com/javascript_examples/iframe_talks_to_parent/
However, the crucial thing to bear in mind is that unless the parent and child are on the same domain, it's not possible to have events passed between them. If your iframe contains a page from a different domain then you're out of luck, I think.