function mousePosition(ev){
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
function mouseMove(ev){
document.onmousemove = mouseMove;
ev = ev || window.event;
var mousePos = mousePosition(ev);
var position = {
y : mousePos.y-10,
x : mousePos.x/2
};
}
javaScript中获取鼠标位置
最新推荐文章于 2024-11-16 14:11:26 发布