Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Getting Mouse Position (http://www.velocityreviews.com/forums/t873181-getting-mouse-position.html)

Andy Levy 10-17-2003 10:36 AM

Getting Mouse Position
 
Hi

I am using the following script to get the mouse x and y position values.
It seems to work in all browsers ok, except for IE on the Mac. Both
xMousePos and yMousePos do not seem to accurately relate to where the mouse
is on the screen. But only in IE on the Mac. Any ideas ?

Thanks
Andy

<!--
if (document.layers) { // Netscape
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
document.onmousemove = captureMousePosition;
}

// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {

if (document.layers) { //Netscape
xMousePos = e.pageX;
yMousePos = e.pageY;
xMousePosMax = window.innerWidth+window.pageXOffset;
yMousePosMax = window.innerHeight+window.pageYOffset;
} else if (document.all) { //IE
xMousePos = window.event.x+document.body.scrollLeft;
yMousePos = window.event.y+document.body.scrollTop;
xMousePosMax = document.body.clientWidth+document.body.scrollLeft ;
yMousePosMax = document.body.clientHeight+document.body.scrollTop ;
} else if (document.getElementById) {

// Netscape 6 behaves the same as Netscape 4 in this regard
xMousePos = e.pageX;
yMousePos = e.pageY;
xMousePosMax = window.innerWidth+window.pageXOffset;
yMousePosMax = window.innerHeight+window.pageYOffset;
}

//window.status = "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos +
", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax;


}




All times are GMT. The time now is 08:52 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.