Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1473 How can I get the current mouse pointer position (ie X,Y coordinates) on the screen?

irt.org | Knowledge Base | JavaScript | Pointer | Q1473 [ previous next ]

Q1473 How can I 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.status= Text;
}
//--></script>
</head>
<body>
Move the mouse and see the status change
</body>
</html>

Feedback on 'Q1473 How can I get the current mouse pointer position (ie X,Y coordinates) on the screen?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.