document.onmousemove = judge 鼠标移动时候调用!! 博客分类: jsp htmljs
程序员文章站
2024-03-21 18:37:10
...
<html>
<head>
</head>
<body>
123333
223
</body>
<script type="text/javascript" >
function judge(){
alert("mousemove");
//document.onmousemove = null;//撤销鼠标移动模拟
}
function simulateMouseMove(){//模拟鼠标移动
document.onmousemove = judge;
}
window.onload=simulateMouseMove;//窗口加载
</script>
</html>
效果: 鼠标在页面上移动就会触发事件
同理将 document.onmousemove = judge; 改成
document.onclick = judge;
效果: 鼠标在页面上点击就会触发事件
<head>
</head>
<body>
123333
223
</body>
<script type="text/javascript" >
function judge(){
alert("mousemove");
//document.onmousemove = null;//撤销鼠标移动模拟
}
function simulateMouseMove(){//模拟鼠标移动
document.onmousemove = judge;
}
window.onload=simulateMouseMove;//窗口加载
</script>
</html>
效果: 鼠标在页面上移动就会触发事件
同理将 document.onmousemove = judge; 改成
document.onclick = judge;
效果: 鼠标在页面上点击就会触发事件