Re: popups in javascript -
05-28-2004
, 12:48 PM
Hi Bob
Had a similar issue a while back. Wrote a little tooltip library.
Here's the bit for getting the position right in case it provides some
clues.
Be a bit caseful. This was for an app where we could specify IE5+ for
it's not browser independent. It was designed to adjust for scrolling
and make sure it stays on the page (x/yOffset are just constants to get
it looking right - 15 in my case)
ToolTip.style.top=event.clientY + yOffset;
ToolTip.style.left=event.clientX + xOffset;
// Adjust X position to stay on the page if required
var l=parseInt(ToolTip.style.left);
var w=parseInt(ToolTip.style.width);
var bw=ToolTipFrame.body.clientWidth-10;
if (w+l>bw)
{
ToolTip.style.left = bw - w;
}
// Adjust Y position to stay on the page if required
var t=parseInt(ToolTip.style.top);
var h=parseInt(ToolTip.style.height);
var bh=ToolTipFrame.body.clientHeight-10;
if (t+h>bh)
{
ToolTip.style.top = event.clientY - h - 20;
}
ToolTip.style.visibility='visible';
Good luck! |