Javascript onmousemove事件在Chrome中不起作用
我在Firefox和IE中为onmousemove事件编写了代码,但在Chrome中没有:Javascript onmousemove事件在Chrome中不起作用,javascript,Javascript,我在Firefox和IE中为onmousemove事件编写了代码,但在Chrome中没有: var mouse; function storeMouse(e) { if (!e) e = window.event; mouse = { clientX: e.clientX, clientX: e.clientY }; } function test(e) {
var mouse;
function storeMouse(e) {
if (!e) e = window.event;
mouse = { clientX: e.clientX, clientX: e.clientY };
}
function test(e) {
alert(mouse.clientX);
if (mouse.clientX < 150) {
var agree = confirm("Are you sure to leave this page");
if (!agree) {
return false;
}
else {
}
}
}
var鼠标;
功能存储鼠标(e){
如果(!e)e=window.event;
鼠标={clientX:e.clientX,clientX:e.clientY};
}
功能测试(e){
警报(mouse.clientX);
如果(mouse.clientX<150){
var agree=确认(“您确定要离开此页”);
如果(!同意){
返回false;
}
否则{
}
}
}
第4行出现问题:重复鼠标。clientX您在哪里调用storeMouse。我们只看到函数定义…window.event实际上是一个IE的东西,我想。。。您是否尝试查看window.addeventListener?我将查看以检查跨浏览器兼容性。在发布的代码中甚至没有提到
mousemove
。请编辑你的问题。只是为了帮助将来的任何人通过谷歌找到这个问题:如果你出于某种原因启用了“模拟触摸事件”,请禁用它。我花了一些时间才弄明白,一点也不好玩。