Firefox issue with getting mouse pos when over dropped down select box

Discussion in 'JavaScript' started by AlexLibman, Aug 21, 2007.

  1. #1
    I have a JS function for tracking current mouse cursor position relative to document body, and the positions are used to display a hidden-by-default "tooltip" div right under cursor - show onmouseover (and/or onmousemove), hide onmouseout.

    It works correctly in all situations I've tried so far except one: when using Firefox and hovering the mouse over a dropped-down <select size="1" ...> box. The tooltip appears to be offset to top-left for some reason. Adding additional HideToolTip() calls for other events (onchange, onblur, onfade) on the select object as well as on the option objects inside it (including onmouseover, onmousemove, etc) do not make the tooltip go away.

    Please open this demo page with Firefox (and view source) to see what I mean: http://www.alexlibman.com/jstest.html

    Thank you in advance. ;)
     
    AlexLibman, Aug 21, 2007 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    With the options displayed, Fx is reporting mouse co-ordinates relative to the options display rather than the document. This can be demonstrated more clearly if you give the select an id of 'sbox', and include the code below
    <script type='text/javascript'>
    document.getElementById('sBox').onmousemove = function(a){TrackMousePosition(a);ShowToolTip ('Select Box Tooltip', 'Tooltip message for SELECT BOX (not individual options) goes here...');}
    </script>
    
    Code (markup):
    It may be better to base the positioning of the tooltip on the co-ordinates of the element, rather than those of the cursor.

    You're welcome in advance.
     
    Logic Ali, Aug 22, 2007 IP