You are here: irt.org | FAQ | JavaScript | Event | Q1374 [ previous next ]
Use pageX and pageY in Netscape navigator 4, and clientX and clientY in Internet Explorer 4+:
<script language="JavaScript"><!-- function coords(e) { if (document.layers) { alert(e.pageX + ',' + e.pageY); } else if (window.event) { alert(window.event.clientX + ',' + window.event.clientY); } } //--></script> <br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br> <form> <input type="button" value="Click me!" onClick="coords(event)"> </form> <br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br>