function MouseCoords(ev)
{
ev = ev || window.event; // remove browser dependency
if(ev.pageX || ev.pageY)
return {x:ev.pageX, y:ev.pageY};
else if (ev.clientX || ev.clientY)
{
var posx = ev.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
var posy = ev.clientY + document.body.scrollTop + document.documentElement.scrollTop;
return { x:posx , y:posy };
}
return { x:-1 , y:-1 }; // invalid/unknown mouse event
}
Note: This function does not work for mouse scrolling in Mozilla FireFox 2.0 or previous versions.
0 Comments:
Post a Comment