473,569 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mouseover only works correctly on second mouseover.

1 New Member
This javascript issue is in an app using C# / .Net 2.0 running on XP.
First post, please mention if I mess up any conventions of this forum.

I’ve got a mouseover event that only works properly the second time it fires if the page has been scrolled a lot. The mouseover displays an image in a div that is placed near the mouse cursor. When the rollover occurs near the bottom of the page, the coordinates are altered so that the entire image is visible – instead of the default location with the top of the image next to the cursor.
This works fine until the user scrolls down. Then, on the mouseover the image appears in its default location even if the cursor is near the bottom of the page so the image is cut off. If you move the cursor off of the location and then back over it, it works correctly.
I output the coordinates of the image and can see that it isn't corrected the first time around, but is the second. It seems to be failing on the line below. This is what determines whether to reset the style.pixelTop of the image.

Thanks in advance, Dave R.

Expand|Select|Wrap|Line Numbers
  1. if (tooltip.style.pixelTop + tooltip.offsetHeight > fullHeight) 
  2.  
  3. Here is all of the relevant code.
  4. ...
  5.     var tooltip = null;
  6.     var txtDisplay = new String();
  7.     var strImgPath = inData;
  8.  
  9.     txtDisplay += "<table><tr><td valign=top>";
  10.     txtDisplay += "<br /><br /><img border=1 src='" + strImgPath + "' /><br /><br />";
  11.     txtDisplay += "</td></tr></table>";    
  12.  
  13.     // IE only
  14.     if (!(document.layers && !document.getElementById)) 
  15.     {
  16.  
  17.         if (document.all) 
  18.         {
  19.             tooltip = document.all.TooltipDIV;
  20.  
  21.             if (!tooltip) 
  22.             {
  23.                 return;
  24.             }
  25.  
  26.             // get position values
  27.             var mouseX = inEvent.clientX;
  28.             var mouseY = inEvent.clientY;
  29.             var fullWidth = document.body.scrollLeft + document.body.offsetWidth - 10;
  30.             var fullHeight = document.body.scrollTop + document.body.offsetHeight - 10;
  31.  
  32.             tooltip.innerHTML = txtDisplay;
  33.  
  34.                 tooltip.style.left = document.body.scrollLeft + mouseX + 20;
  35.             tooltip.style.top = document.body.scrollTop + mouseY - 50; 
  36.  
  37.             tooltip.style.display = "block";
  38.             tooltip.style.visibility = "visible";
  39.             tooltip.style.position = "absolute";
  40.  
  41.             if (tooltip.style.pixelTop + tooltip.offsetHeight > fullHeight) 
  42.             {
  43.                 tooltip.style.pixelTop = (document.body.scrollTop + document.body.offsetHeight) - tooltip.offsetHeight - 10;
  44.             }
  45.  
  46.         }
  47.  
  48. ...
  49.  
Dec 13 '07 #1
1 1952
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

Perhaps you could try:
Expand|Select|Wrap|Line Numbers
  1. if ((tooltip.style.pixelTop + tooltip.offsetHeight) > fullHeight)
Dec 14 '07 #2

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

Similar topics

3
1772
by: richk | last post by:
For some reason when I add additional buttons a 3rd button and beyond i cant get the effect to work and I get errors...I cant understand why... <SCRIPT LANGUAGE = "javascript"><!-- if (document.images) { // Active Images img1on = new Image(); img1on.src = "button1_on.jpg";
14
2327
by: J. Makela | last post by:
Hallo. This should be a pretty entertaining question for you *real* javascript writers.. I, being the lowly photoshop guy at an ad agency made the mistake of actually saying "HTML" in a conversation once.. and now I have been tasked with building a big website with LOTS of fancy javascripting. Image rollovers mostly. Only problem is that I...
2
5165
by: Mitch | last post by:
I am hosting a web browser ctl in a container that implements the IDocHostUIHandler interface. I'm using this to control the context menu.This works fine. Then, I added a mouseover event to the document in the documentComplete event handler. When I add this event handler, I loose all other navigation functions in the browser! right...
5
2391
by: JB | last post by:
I am struggling to figure out a way to allow one element to be dragged, but still capture 'mouseover' events on other elements. I've created a simple example to demonstrate what I mean: http://gerromorpha.cs.uoregon.edu/moveAndOver.html (The above link is only meant for Windows/Firefox.) It's not much code, but it's probably too much to...
1
2655
by: giloosh | last post by:
Hello All, How can you continue the mouseover event while the mouse is still over an object? For example: I put my mouse over a hyperlink and that triggers an object to move 10px to the right. I want the object to continue moving 10px to the right every 1 second untill i take my mouse off of the hyperlink.
3
19492
by: Annette Acquaire | last post by:
I have and image map with a dozen hotspot links on it that I'm trying to get to open a new image over existing one on mouseover of each COORD. The only thing I was able to do was swap image on mouseover entire image, I want it on each hotspot only, so an image pertaining to each link shows up. I have done it in JavaScript, but the website I'm...
23
2738
by: Schannah | last post by:
I'm trying to create a design which mimics the Radiohead website in the action on this page, but the problem is that they use PHP for the effect and I have no idea about PHP. I'm very amateur: fairly confident with HTML and can scrape together codes with JavaScript with a lot of research and cursing, but for the life of me I can't see how to...
10
2672
by: jjamjatra | last post by:
I am struggling with a event model handling problem in Javascript that shows up only in Firefox. I have 2 little websites I'd like you to take a look at: http://gis.cbmiweb.com/MexicoExported/default.asp http://gis.cbmiweb.com/MDWmaps/default.asp The issue involves the code behind the "Zoom Box"...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7917
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.