ScrollTop Issue in Firefox

V

velhari

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top