我正在使用这段代码来检测鼠标离开窗口,它运行得非常好。
但在Chrome中,即使触摸滚动条,此代码仍会返回鼠标离开事件。我该如何防止这种情况发生?请给出建议。
我正在使用以下代码:`addEvent(document, "mouseleave", function(e) {`
jQuery(document).mouseleave(function(){console.log('out')})
jQuery(document).mouseenter(function(){console.log('in')});
但在Chrome中,即使触摸滚动条,此代码仍会返回鼠标离开事件。我该如何防止这种情况发生?请给出建议。
我正在使用以下代码:`addEvent(document, "mouseleave", function(e) {`
e = e ? e : window.event;
var from = e.relatedTarget || e.toElement;
jQuery(document).mouseleave(function(){
if (!from || from.nodeName == "HTML") {
$(".tso_popup_wrapper")
.animate({"width":"400px","height":"200px"},100)
.animate({"right":"100px", "top":"107px"},500)
.animate({"width":"1000px", "height":"700px"},1)
.animate({"right":"-100px", "top":"107px"},1)
.animate({"width":"1350px", "height":"700px"},1)
.animate({"right":"-298px", "top":"107px"},250);
$('.navigation-all').slideDown(300);
console.log('out');
}
});
`
element.width - element.scrollWidth
。不确定是否有效,但可以试试! - Praveen Kumar Purushothaman