Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Tooltip, problem with scrolling

Status
Not open for further replies.

jesperthor

Technical User
May 17, 2003
11
SE
Hello, I’m trying to add ‘Tool-tip’ to my images. I have one problem though. If you look at and rollover the first image a fancy “tip” will be displayed exactly where the courser are at the time. But if use the mousewheel (or the scrollbars to scroll down to the second image, the tip will displayed on wrong X & Y coordinates. I tired a different script called “overlib” and have the same result. It didn’t help that the overlibscript was in +1300 rows of code. This is the js code:

function showInfo(msg)
{
var X,Y
X = event.clientX;
Y = event.clientY;

document.all["info"].style.left = X;
document.all["info"].style.top = Y;
document.all["info"].innerHTML = msg;
document.all["info"].style.visibility = "visible";
}

And HTML:

<img src=&quot;knuff.gif&quot; width=&quot;384&quot; height=&quot;512&quot; onmousemove=&quot;showInfo('detta är en paragraf<br> Paragrafer är stycken i en text<p>Paragrafer är bra')&quot; onmouseout=&quot;document.all['info'].style.visibility = 'hidden'&quot;>

<div id=&quot;info&quot; style=&quot;visibility:hidden&quot;/>

Thanks for your time!
 
Jesper,

If you change the following line(s):

Code:
document.all[&quot;info&quot;].style.top = Y;

to read:

Code:
document.all[&quot;info&quot;].style.top = Y + document.getElementsByTagName('body')[0].scrollTop;

Then all works as expected.

Hope this helps!

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top