Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to use event.ClientX and Y

    Hello,

    here is the code I come up with.

    Code:
    <html>
    <head>
    <script type="text/javascript">
    <!--
    
    var posX;
    var posY;
    
    function position()
    {
    
    posX=event.ClientX;
    posY=event.ClientY;
    alert(posX);
    alert(posY);
    
    }
    
    
    -->
    </script>
    </head>
    <body onMouseMove="position()">
    </body>
    </html>
    I did try to do this:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    <!--
    
    function position()
    {
    
    alert(event.ClientX);
    alert(event.ClientY);
    
    }
    
    
    -->
    </script>
    </head>
    <body onMouseMove="position()">
    </body>
    </html>
    but there was the same result:
    The alert boxes say "undifined" instead of revealing the X and Y position of the cursor.
    Why is this not working?

    Thanks
    Shawn

  • #2
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's client, not Client. You need to remember, JavaScript is case sensitive.
    Moderator @ WebDeveloper.com
    Mentor @ WebXpertz.net

  • #3
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    OMG, I can't beleive THAT'S my mistake!!!

    Thank you very much!
    Shawn

  • #4
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No problem! It's a very common mistake.
    Moderator @ WebDeveloper.com
    Mentor @ WebXpertz.net


  •  

    Posting Permissions

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