Onmousemove无法在Google Chrome浏览器中工作 [英] Onmousemove not working in Google Chrome

查看:364
本文介绍了Onmousemove无法在Google Chrome浏览器中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为mousemove事件编写了代码.但是它在IE和firfox中效果很好,但在Google chrome中效果不佳.....

我的代码在这里.....

I have coding for on mousemove event.But it working well in IE and firfox but not in Google chrome........

MY code is here.....

var mouse;
             function storeMouse(e) {
                 if (!e) e = window.event;
                 mouse = { clientX: e.clientX, clientX: e.clientY };
             }

             function test(e) {
//                 debugger;
                 alert(mouse.clientX);
                 if (mouse.clientX < 150) {
                     var agree = confirm("Are you sure to leave this page");
                     if (!agree) {
                         return false;
                     }
//                     else {
//
//                     }
                 }
             }
<body onbeforeunload="test(event);" onmousemove="storeMouse(event);">



谁能帮我.....

谢谢....



Can anyone help me.....

Thanks....

推荐答案



如果您的要求是在浏览器窗口关闭时提醒用户,则也可以这样实现:



if your requirement is to alert the user on the browser window close then it can also be achieved like this:

var inFormOrLink;


(' a').live(' 点击',函数(){inFormOrLink = true ;});
('a').live('click', function () { inFormOrLink = true; });


(' form').bind(' submit',函数(){inFormOrLink = true ;});
('form').bind('submit', function () { inFormOrLink = true; });


这篇关于Onmousemove无法在Google Chrome浏览器中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆