[Javascript] Re: how do I do event.clientX in Netscape?

Lewis Shadoff lshadoff at brazosport.cc.tx.us
Wed Mar 27 12:27:03 CST 2002


At 09:46 AM 3/27/02, Lau wrote:
>How do I detect the current cursor position in NN4.7  and in NN6?
>
>In IE I use the following:
>
>var x=event.clientX;
>var y=event.clientY;
>
>but it doesn't work in Netscape :-(

Here is a simple script which displays the cursor position in the status 
bar in NN4.7 (doesn't work in NN6 or IE):

<!--
function mouseProc() {
         window.captureEvents(Event.MOUSEMOVE);
         window.onmousemove = showPos;
}
function showPos(e) {
if (e.which == 1) {
         var xPos = e.pageX;
         var yPos = e.pageY;
         window.status = "x = " + xPos + " y = " + yPos;
}
}
//-->

Call it up in the body tag:

body onLoad=mouseProc()

Lew



Lewis A. Shadoff, Ph.D.
Brazosport College
Lake Jackson, TX





More information about the Javascript mailing list