87,919
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<head>
<title></title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<script type="text/javascript">
var oldX = "";
var oldY = "";
var result = "";
if (navigator.appName == 'Netscape') {
// 支持FF
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = netscapeMouseMove;
} else {
// 支持IE
document.onmousemove = MouseMove;
}
function netscapeMouseMove(e) {
if (e.screenX != document.getElementById('x').value
&& e.screenY != document.getElementById('y').value) {
document.getElementById('x').value = e.screenX;
document.getElementById('y').value = e.screenY;
if (!oldX) {
oldX = document.getElementById('x').value;
oldY = document.getElementById('y').value;
}
}
}
function MouseMove() {
if (window.event.x != document.getElementById('x').value
&& window.event.y != document.getElementById('y').value) {
document.getElementById('x').value = window.event.x;
document.getElementById('y').value = window.event.y;
if (!oldX) {
oldX = document.getElementById('x').value;
oldY = document.getElementById('y').value;
}
}
}
</script>
</head>
<body>
X:<input id="x" size="4">
Y:<input id="y" size="4">
</body>
<script type="text/javascript">
function aaa(a){
alert('ddddd'+a)
}
(function getXY() {
var x = document.getElementById('x').value;
var y = document.getElementById('y').value;
if (oldX != "" && (x != oldX || y != oldY)) {
if (x > oldX && y == oldY) {
result = '鼠标相对前5秒向右移动';
}
if (x < oldX && y == oldY) {
result = '鼠标相对前5秒向左移动';
}
if (x < oldX && y > oldY) {
result = '鼠标相对前5秒向左下移动';
}
if (x < oldX && y < oldY) {
result = '鼠标相对前5秒向左上移动';
}
if (x > oldX && y < oldY) {
result = '鼠标相对前5秒向右上移动';
}
if (x > oldX && y > oldY) {
result = '鼠标相对前5秒向右下移动';
}
if (x == oldX && y > oldY) {
result = '鼠标相对前5秒向下移动';
}
if (x == oldX && y < oldY) {
result = '鼠标相对前5秒向上移动';
}
oldX = document.getElementById('x').value;
oldY = document.getElementById('y').value;
} else {
result = '没有变化';
}
ajax()传result到后台 //这块就不用我写了吧 呵呵
setTimeout(getXY, 300000);
})();
</script>
</html>