点击并拖动溢出元素:隐藏不会触发onmouseout在Firefox中
问题描述:
它在Chrome中正常工作,但不是在Firefox中,在Firefox中它会在触发器之外触发,然后移动光标。任何想法是什么导致这种行为,有没有办法解决它?点击并拖动溢出元素:隐藏不会触发onmouseout在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
答
添加的最后一行。 firefox有默认的拖拽功能,所以可以防止鼠标拖曳时的默认值。
var testDiv = document.getElementById("testDiv");
testDiv.onmouseout = function() {
alert("Triggered.");
};
testDiv.onmousedown=function(e){e.preventDefault();}
一旦我将鼠标移出盒子后,它就会触发。这不适合你吗? – Brian 2014-09-21 00:27:39
是的,但是为什么它不像铬合金一样,在你离开盒子时触发正确? – Mandera 2014-09-21 00:29:07
您的Firefox版本是什么? – Hamix 2014-09-21 11:18:17