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 2 of 2
  1. #1
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts

    absolute x y mouse positions

    i am doing a script where i click on an image and it gets the x and y position of the cursor, i got it all working fine in the system it is part of and stuff apart from that when you scroll across it is clear that the x/y positions are on the broser window, so if i scroll down, it thinks its where it would be if i clicked on the same place without scrolling

    is there a different way to get x/y positions than this or a way to make sure it knows where on the pic i have clicked after i have scrolled down

    edit: atm i am using
    Code:
    if(document.layers) document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = track;
    
    var x, y
    
    function track(e)
    {
    	x = (document.all) ? event.x : e.pageX;
    	y = (document.all) ? event.y : e.pageY;
    }
    and an onmouseclick on the image that runs a function with the x&y values
    Last edited by ghell; 08-13-2004 at 04:54 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Add this to your x / y coordinates:
    IE:
    document.body.scrollLeft
    document.body.scrollTop
    all other:
    window.pageXOffset
    window.pageYOffset

    dumpfi


  •  

    Posting Permissions

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