Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1374 When capturing an event, is there any way to find out the mouse position relative to the page?

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>

Feedback on 'Q1374 When capturing an event, is there any way to find out the mouse position relative to the page?'

©2018 Martin Webb