PDA

View Full Version : mouse posistion in window


kwhubby
11-26-2002, 06:56 AM
whats the way to get the x, y coordinates for the mouse pointer, ive seen it done in javascript for a moving div tag that acted sorta like the alt text for links and things.

requestcode
11-26-2002, 06:08 PM
Here is a script that I got a long time ago from here, but not sure if it still works with all the borwsers.
<html>
<head>
<title>Mouse Position</title>
<SCRIPT LANGUAGE=JavaScript1.2>
<!--//
// This script was provided by John Krutsch of www.wsabstraction.com
function tracker(e)
{
if(document.all) // IE5
{
window.status=event.clientX+","+event.clientY; return true;
}
else
{
if(document.getElementById) // NS6
{
window.status=e.screenX+" "+e.screenY
}
}
if(document.layers) // ns4
{
window.status=e.x+","+e.y; return true;
}
}
if(document.layers) // NS4 only
{
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove=tracker
//-->
</SCRIPT>
</head>
<body >

</body>
</html>

kwhubby
11-27-2002, 09:19 AM
eww thanks a bunch for that