HighDots Forums  

problems with positions

alt.html.dhtml alt.html.dhtml


Discuss problems with positions in the alt.html.dhtml forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kasper Birch Olsen
 
Posts: n/a

Default problems with positions - 07-22-2003 , 11:01 AM






Hi

Im making an advanced tooltip for my page, but ive run into a problem.
The yellow box is made of a span tag thats positioned absolutely and
moved around to the different objects that needs to show a tooltip. But
when the object is too close to the buttom of the screen the tooltip is
positioned outside the layout of the page, and completly ruins my
design. so basicaly I want to calculate if the div tag is (partly)
positioned outside the document area, before I make it visible. My code
is very simple:

function findPosX(obj) {
var curleft = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curleft +=obj.offsetLeft
obj = obj.offsetParent;
}
} else if (obj.x)
curleft += obj.x;
return curleft;
}
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;
}

function showHint(showThis, underThis) {
elem = document.getElementById(showThis);
elem2 = document.getElementById(underThis);
elem.style.left = findPosX(elem2);
elem.style.top = findPosY(elem2)+15;
elem.style.visibility='visible';
}

function hideHint(hideThis) {
elem = document.getElementById(hideThis);
elem.style.visibility='hidden';
}

and what I want to do is to calc new style.left and style.top for elem
if its outside the document. I just dont have a clue as to how its done!

can someone give me a few hints?

- Kasper


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 - 2009, Jelsoft Enterprises Ltd.