position of link on IE6 browser

S

soup_or_power

Hello
I'm trying to assign the position of a popup the same as a link.
The position of link is coming out ok. But the popup is not
being shown at the left,top coordinates of the link. I'm using IE6 and
getting workedup like silly. I'd appreciate your help.
Thank you

document.getElementById('popup').style.visibility="visible";
var top= document.body.scrollTop +
document.getElementById('link1').offsetTop;
document.getElementById('popup').style.top=top;
var left =document.body.scrollLeft +
document.getElementById('link1').offsetLeft;
document.getElementById('popup').style.left=left;
 
S

soup_or_power

How can I display the popup relative to the top of the frame. Using the
offsetTop and offsetLeft the popups appear at the bottom of the frame.
Thanks for your help
 
P

Peter Schaefer

Try this and let me know what pops up (if anything)
document.getElementById('popup­').style.visibility="visible";
var top= document.body.scrollTop +
document.getElementById('link1­').offsetTop;
document.getElementById('popup­').style.top=top;
var left =document.body.scrollLeft +
document.getElementById('link1­').offsetLeft;
document.getElementById('popup­').style.left=left;

alert(document.getElementById('link1­').offsetTop)
alert(document.getElementById('link1­').offsetLeft)

if you get nothing, then there's your problem.If the values were not
set by js, this is likely.
if you get something like '200px' then you are adding strings to
numbers and
will get the wonderful value 'NaN' which is no good.

let me know.

TheGeek
 
S

soup_or_power

Hi Peter

All the popup's are placed on the top-left corner instead
of on the links. The alerts showed numbers --- no px.

Thanks for your help.
 
S

soup_or_power

Why can't I position a popup over a link when the tooltip gets
positioned exactly where I want to position the popup?

Thanks for your help.
 
S

soup_or_power

I fixed my problem. The solution is at
http://www.quirksmode.org/js/findpos.html. Thanks for all your help!

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;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top