Results 1 to 2 of 2

Thread: Current x,y of the mouse?

  1. #1

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post Current x,y of the mouse?

    Does anyone know how to get the current x,y of the mouse pointer in JavaScript?

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  2. #2
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237
    Code:
    <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.defaultStatus = text;
    }
    //--></script>
    </head>
    <body>
    Move the mouse and see the status change
    </body>
    </html>
    Another light-hearted post from Guru

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width