NorthStarDA
IS-IT--Management
i need to get the location of an element relative to the entire window, but the element is inside an iframe- i'm using the functions below to loop through offsetParents, but iframes apparently do not have an offsetParent. so they return the location relative to the iframe the element is in, not the main outer window- how can i get that?
=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
Code:
function findPosX(obj)
{
var x1 = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
x1 += obj.offsetLeft;
obj = obj.offsetParent;
}
}
else if (obj.x)
x1 += obj.x;
return x1;
}
function findPosY(obj)
{
var y1 = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
y1 += obj.offsetTop;
obj = obj.offsetParent;
}
}
else if (obj.y)
y1 += obj.y;
return y1;
}
=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison