将iframe中的鼠标事件传播到托管文档 [英] Propagating mouse events from iframes to the hosting document

查看:95
本文介绍了将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.

我有什么选择?

推荐答案

几周前我被要求调查一个项目。它可以做到这一点,这里有一个实际的例子:

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/

然而,重要的是要记住除非父和子在同一个域上,否则不可能在它们之间传递事件。如果你的iframe包含来自不同域的页面,那么我认为你运气不好。

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.

这篇关于将iframe中的鼠标事件传播到托管文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆