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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tooltip - absolute position issue with scrolling browswer

Status
Not open for further replies.

clone45

Programmer
Mar 28, 2006
22
US
Hello!

I'm trying to position a javascript tool-tip based on the position of a button. I found this code online for finding the y-offset of the button:

Code:
function findPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

This works great until the user scrolls the broswer window down. Then the position is incorrect, and my tooltip ends up waaaay down the page instead of adjacent to the button.

Any ideas?

Thanks!
- Bret
 
I suspect you are setting your tip box relative to the window and not to the element it comes up for so when the screen scrolls it stays where it was.

Most of the time you would want the tip to disappear if the mouse is no longer pointing at the element that spawned it.

Look at this thread where I have posted tool tip code I have been working on. thread216-1212863

Paranoid? ME?? Who wants to know????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top