|
Q1146 How do you get the current mouse pointer position (ie X,Y coordinates) on the screen?
irt.org | Knowledge Base | JavaScript | Pointer | Q1146 [ previous next ]
Q1146 How do you get the current mouse pointer position (ie X,Y coordinates) on the screen?
Try:
<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>
|
Feedback on 'Q1146 How do you get the current mouse pointer position (ie X,Y coordinates) on the screen?'
|
|
Copyright © 1996-2009 irt.org, All Rights Reserved.