473,394 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

ScrollTop Issue in Firefox

46
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
Expand|Select|Wrap|Line Numbers
  1. <div id="overflowdiv" style="overflow:scroll;height:100;width:100">
  2.     <ul style="list-style-type:none">
  3.         <li><a href="javascript:void(0);" onMouseOver="getScrollTop(this)">Test Element 1</a></li>
  4.         <li><a href="javascript:void(0);" onMouseOver="getScrollTop(this)">Test Element 2</a></li>
  5.         <li><a href="javascript:void(0);" onMouseOver="getScrollTop(this)">Test Element 3</a></li>
  6.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 4</a></li>
  7.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 5</a></li>
  8.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 6</a></li>
  9.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 7</a></li>
  10.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 8</a></li>
  11.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 9</a></li>
  12.         <li><a href="javascript:void(0);" onMouseOver="getScrollTop(this)">Test Element 10</a></li>
  13.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 11</a></li>
  14.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 12</a></li>
  15.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 13</a></li>
  16.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 14</a></li>
  17.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 15</a></li>
  18.         <li><a href="javascript:void(0);" onmouseover="getScrollTop(this)">Test Element 16</a></li>
  19.     </ul>
  20. </div>
  21. <div id="showdiv" style="left:-100;top:-100;position:absolute;background-color:#FFFF00;color:#000000">Please help me to resolve this issue</div>
  22. <script language="javascript">
  23.     function getScrollTop( element ){
  24.         var l = t = 0;        
  25.         while( element != null ) {
  26.             l += element.offsetLeft;
  27.             t += element.offsetTop;                        
  28.             if ( element.nodeName != 'BODY' ){                 
  29.                 l -= element.scrollLeft;
  30.                 t -= element.scrollTop;
  31.             }
  32.             element = element.offsetParent;
  33.         }
  34.         document.getElementById('showdiv').style.left = l;
  35.         document.getElementById('showdiv').style.top  = t;
  36.     }
  37. </script>
  38.  
  39.  
Please tell me what is the problem
Jun 17 '08 #1
3 3125
acoder
16,027 Expert Mod 8TB
When setting top/left, you need to add the units, e.g. "px".
Jun 17 '08 #2
Velhari
46
When setting top/left, you need to add the units, e.g. "px".
Thanks for your reply.

After applying this also, it shouldn't work at all.
Jun 17 '08 #3
acoder
16,027 Expert Mod 8TB
Ah I see. There's no need to work out offsetLeft, etc. if all you want is the mouse position. See this link.
Jun 17 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: London Boy | last post by:
Hi, i've done a script that makes a DIV appear and follow the mouse cursor and it works fine but, it has a small glitch, when i scroll the document, the DIV doesn't appear beside the cursor but...
1
by: Csaba Gabor | last post by:
In the following (IE only) mini page (a table which is supposed to have a fixed header), when you first do anything with the scroll bar, you will see the top two rows of the table jump slightly (a...
2
by: Axel Schick | last post by:
Hello everybody! I encountered a strange behavior when trying to read the scrollTop propery of the <body> element from inside an iFrame: <body onmousemove = "window.status =...
6
by: michaelzap | last post by:
I can't seem to remove some extra margin/padding from my design on this site: http://www.kyowa-usa.com/ IE displays it properly (no space between the menus and other elements and the outer...
0
by: gregtyndall | last post by:
I have a weird problem. I'm using a master page to hold a menu that I want to scroll as the user scrolls in the browser window so it will always be visible. First off, putting onsroll in the body...
9
by: Andy | last post by:
Hey all, I'm building out my first project using asp.net v2.0 master pages. It seems that when you use master pages and try to reference document.body.scrollTop it allways = zero/0. The same code...
0
by: bluegrasslover | last post by:
I've gotten a couple of emails about this problem lately so I'm going to post the solution that someone emailed me a while back. When you create a master page visual studio automatically adds a...
2
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I created a complex ASPX page, nested inside a master page and Ajax UpdatePanel. In one of my Javascript function I need to capture mouse position. I use alert(document.body.scrollTop) to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.