我想在鼠标离开窗口时显示警告。像http://ezwebsitebiz.com/testing-content/
一样我想在jquery中这样做。它是如何实现的
答案 0 :(得分:0)
var currentMousePos = { x: -1, y: -1 };
jQuery(document).mousemove(function(event) {
currentMousePos.x = event.pageX;
currentMousePos.y = event.pageY;
});
jQuery(document).mouseleave(function() {
var window_width = jQuery(window).width();
var window_height = jQuery(window).height();
if((currentMousePos.x < window_width) && (currentMousePos.y > 50))
return true;
alert(currentMousePos.x.toString());
})
用弹出窗口或花式框替换警告消息