IE中的鼠标位置

时间:2014-11-05 13:06:15

标签: javascript jquery html internet-explorer

当光标仅到达浏览器顶部(导航到选项卡)时,我必须显示警告消息,但在移动到任务栏和滚动条时不显示。我尝试使用pageXpageY,但Internet Explorer中的值有所不同请帮我解决此问题。

$('html').mouseleave(function(e) {
   if((e.pageY <= 5+$(window).scrollTop() && e.pageX >= ($(window).width() * 0/100 ))){
        alert("hai");
   }
)

这会在firefox和chrome中显示警报,但不会显示在

1 个答案:

答案 0 :(得分:0)

尝试使用jQuery

var currentMousePos = { x: -1, y: -1 };
$(document).mousemove(function(event) {
    currentMousePos.x = event.pageX;
    currentMousePos.y = event.pageY;
});

有了这个,你可以在客户端获得鼠标的位置