Getting the current cursor position using clientX,clientY

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Hammond

    Getting the current cursor position using clientX,clientY

    I have an html element (a link) with an onclick handler which opens a
    popup window, and would like to position that window at the coordinates
    where the element appears on the page. I have installed a
    document.onclic k event handler which saves the eventX and eventY
    values, then use those values to set the window top/left coordinates.

    The problem is that the eventX and eventY values always seem to be the
    previous coordinates, not the current ones. In other words, the first
    time that I click the element, no coordinates have been set. The next
    time I click the element, the coordinates from the first click have
    been saved. Because there are multiple clickable elements on the page,
    the effect is that the popup window is always opening at the previous
    cursor position rather than the current position.

    It seems like my document.onclic k event handler is being called after
    the onClick handler defined for the particular HTML element.

    Can anyone provide info on how I can detect the current cursor position
    before the element-specific onClick handler executes?
    Thanks!

    -Dave H.

  • Fred Oz

    #2
    Re: Getting the current cursor position using clientX,clientY

    Dave Hammond wrote:[color=blue]
    > I have an html element (a link) with an onclick handler which opens a
    > popup window, and would like to position that window at the coordinates
    > where the element appears on the page. I have installed a
    > document.onclic k event handler which saves the eventX and eventY
    > values, then use those values to set the window top/left coordinates.[/color]

    Have a read of:


    <URL:http://evolt.org/article/Mission_Impossi ble_mouse_posit ion/17/23335/index.html>

    and:

    <URL:http://www.quirksmode. org/index.html?/js/events_compinfo .html>

    --
    Fred

    Comment

    Working...