Iframe阻止发生鼠标移动事件 [英] Iframe obstructing the mousemove event from occuring

查看:134
本文介绍了Iframe阻止发生鼠标移动事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我附上身体事件。但透明Iframe出现在弹出框后面的主体上。我想在body上调用mousemove事件,以便在iframe发生鼠标移动时弹出消失。

>我以前遇到过这个问题。当你向 body 添加一个 iframe 会发生什么事情,通常会发送到像mousemove这样的主体的事件是被这个iframe阻挡。



我已经通过添加一个绝对位置 div 来修正100%高度,宽度在iframe上,只要弹出窗口打开。这 div 应该有更高的z-index作为 iframe



您可以在 div 中监听 body 中的mousemove,而不是监听 div。每当您关闭弹出窗口时,请移除 div


I attached an event on body. But a transparent Iframe appears on the body behind the popup. I want to call that mousemove event on the body, so that the popup disappears as soon as the mousemove occurs on the iframe.

解决方案

I've had an issue with this before. What happens when you add an iframe to the body is that events that would normally be sent to the body like mousemove are being obstructed by that iframe.

I've fixed this by adding a absolute positioned div with 100% height and width over the iframe, whenever the popup opens. This div should have a higher z-index as the iframe.

Instead of listening to mousemove on the body you could then listen to the div. Remove the div whenever you are closing the popup.

这篇关于Iframe阻止发生鼠标移动事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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