ScrollTop Issue in Firefox

Discussion in 'Javascript' started by velhari, Jun 17, 2008.

  1. velhari

    velhari Guest

    Hi all,

    I was showing the popup while hovering over an element under overflow
    div. so i am getting top and left of current hovering element to
    display popup with that top and left position.
    In IE it positioned exactly where i was hovering, But in firefox it
    was misplaced under the overflow div[Not exactly what position i
    hovered]

    My sample code
    <div id="overflowdiv" style="overflow:scroll;height:100;width:100">
    <ul style="list-style-type:none">
    <li><a href="Javascript:void(0);"
    onMouseOver="getScrollTop(this)">Test Element 1</a></li>
    <li><a href="Javascript:void(0);"
    onMouseOver="getScrollTop(this)">Test Element 2</a></li>
    <li><a href="Javascript:void(0);"
    onMouseOver="getScrollTop(this)">Test Element 3</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 4</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 5</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 6</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 7</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 8</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 9</a></li>
    <li><a href="Javascript:void(0);"
    onMouseOver="getScrollTop(this)">Test Element 10</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 11</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 12</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 13</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 14</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 15</a></li>
    <li><a href="Javascript:void(0);"
    onmouseover="getScrollTop(this)">Test Element 16</a></li>
    </ul>
    </div>
    <div id="showdiv"
    style="left:-100;top:-100;position:absolute;background-
    color:#FFFF00;color:#000000">Please help me to resolve this issue</
    div>
    <script language="javascript">
    function getScrollTop( element ){
    var l = t = 0;
    while( element != null ) {
    l += element.offsetLeft;
    t += element.offsetTop;
    if ( element.nodeName != 'BODY' ){
    l -= element.scrollLeft;
    t -= element.scrollTop;
    }
    element = element.offsetParent;
    }
    document.getElementById('showdiv').style.left = l;
    document.getElementById('showdiv').style.top = t;
    //return {left:l, top:t};
    }
    </script>
    Please tell me what is the problem
     
    velhari, Jun 17, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    5,936
  2. =?Utf-8?B?QW5keQ==?=

    master pages and scrollTop = 0

    =?Utf-8?B?QW5keQ==?=, May 17, 2006, in forum: ASP .Net
    Replies:
    9
    Views:
    3,390
    Ken Cox [Microsoft MVP]
    May 17, 2006
  3. Replies:
    0
    Views:
    694
  4. Replies:
    0
    Views:
    1,165
  5. =?Utf-8?B?SGFyZHkgV2FuZw==?=

    HTML document.body.scrollTop question

    =?Utf-8?B?SGFyZHkgV2FuZw==?=, Feb 22, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    1,708
    bruce barker
    Feb 23, 2007
Loading...

Share This Page