繁体   English   中英

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

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

它在chrome中可以正常工作,但在Firefox中却不能,在Firefox中,一旦您在框外释放,然后移动光标,它就会触发。 有什么想法会导致这种行为,并且有什么办法可以解决?

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

因此,在绿色方框内单击并按住,然后将光标移到外面。

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

添加最后一行。 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