You are here: irt.org | FAQ | JavaScript | Pointer | Q1152 [ previous next ]
The following works in Netscape Navigator 4+ and Internet Explorer 4+:
<html> <head> <script language="JavaScript"> if (document.layers) { window.captureEvents(Event.MOUSEMOVE); window.onmousemove=move; } else if (document.all) document.onmousemove=move; function move(e) { if (document.all) document.myForm.x.value=window.event.clientX, document.myForm.y.value=window.event.clientY; else if (document.layers) document.myForm.x.value=e.pageX, document.myForm.y.value=e.pageY; } //--></script> </head> <body> <form name="myForm"> <input type="text" name="x"> <input type="text" name="y"> </form> </body> </html>