Iframe阻止发生鼠标移动事件 [英] Iframe obstructing the mousemove event from occuring
问题描述
我附上身体事件。但透明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屋!