HighDots Forums  

Re: popups in javascript

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: popups in javascript in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
johnboy
 
Posts: n/a

Default 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!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.