PDA

Click to See Complete Forum and Search --> : Current x,y of the mouse?


prog_tom
Jan 15th, 2002, 05:47 PM
Does anyone know how to get the current x,y of the mouse pointer in JavaScript?

Guru
Jan 16th, 2002, 04:00 AM
<html>
<head>
<script language="JavaScript"><!--
if (document.layers) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=mtrack;

function mtrack(e) {
var text = 'Coordinates: ';
if (document.layers) text += e.pageX + ',' + e.pageY
else text += event.x + ',' + event.y;
window.defaultStatus = text;
}
//--></script>
</head>
<body>
Move the mouse and see the status change
</body>
</html>