简体   繁体   English

单击并拖动带有溢出的元素:隐藏不会在firefox中触发onmouseout

[英]Click and drag element with overflow: hidden doesn't trigger onmouseout in firefox

It works fine in chrome but not in firefox, in firefox it triggers once you release outside the box, and then move your cursor. 它在chrome中可以正常工作,但在Firefox中却不能,在Firefox中,一旦您在框外释放,然后移动光标,它就会触发。 Any ideas what causes this behaviour and are there any ways around it? 有什么想法会导致这种行为,并且有什么办法可以解决?

 var testDiv = document.getElementById("testDiv"); testDiv.onmouseout = function () { alert("Triggered."); }; 
 #testDiv { overflow: hidden; width: 100px; height: 100px; background-color: green; } 
  <div id="testDiv"></div> 

So click and hold inside the green square, then move your cursor outside. 因此,在绿色方框内单击并按住,然后将光标移到外面。

Mirror on JSFiddle: http://jsfiddle.net/5ntLgyow/ 在JSFiddle上镜像: http : //jsfiddle.net/5ntLgyow/

Add the last line. 添加最后一行。 firefox has default function for drag so prevent default on mouse down will do. firefox具有默认的拖动功能,因此可以防止鼠标向下默认设置。

var testDiv = document.getElementById("testDiv");
testDiv.onmouseout = function () {
    alert("Triggered.");
};

testDiv.onmousedown=function(e){e.preventDefault();}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM