function getMousePos(ev) {
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
var x = ev.pageX || ev.clientX + scrollX;
var y = ev.pageY || ev.clientY + scrollY;
return { 'x': x, 'y': y };
}
function done(ev){
document.getElementById("show").innerHTML=getMousePos(ev).x+','+getMousePos(ev).y;
};
window.onload=function(){
var odiv=document.getElementById("antzone");
odiv.onmousemove=function(ev){
var ev=window.event||ev;
done(ev);
}
1 个回复
wudi199553
赞同来自: qwer535305054
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
var x = ev.pageX || ev.clientX + scrollX;
var y = ev.pageY || ev.clientY + scrollY;
return { 'x': x, 'y': y };
}
function done(ev){
document.getElementById("show").innerHTML=getMousePos(ev).x+','+getMousePos(ev).y;
};
window.onload=function(){
var odiv=document.getElementById("antzone");
odiv.onmousemove=function(ev){
var ev=window.event||ev;
done(ev);
}