HighDots Forums  

ScrollTop Issue in Firefox

Javascript JavaScript language (comp.lang.javascript)


Discuss ScrollTop Issue in Firefox in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
velhari
 
Posts: n/a

Default ScrollTop Issue in Firefox - 06-17-2008 , 01:43 AM






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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.