S
Seth Illgard
Hi. I need to obtain the exact postion of a div. I was using
(variable and function names are in spanish, sorry):
//Get X position
function obtenerPosicionX(elemento)
{
var x=0;
while(elemento)
{
x += elemento.offsetLeft;
elemento=elemento.offsetParent;
}
return x;
}
//Get Y position
function obtenerPosicionY(elemento)
{
var y=0;
while(elemento)
{
y += elemento.offsetTop;
elemento=elemento.offsetParent;
}
return y;
}
It works great!, except when the div (elemento in my script) is inside
an absolute positioned div. I need to obtain the coordintes no matter
where in the DOM tree the div is.
Any ideas? Thanks
(variable and function names are in spanish, sorry):
//Get X position
function obtenerPosicionX(elemento)
{
var x=0;
while(elemento)
{
x += elemento.offsetLeft;
elemento=elemento.offsetParent;
}
return x;
}
//Get Y position
function obtenerPosicionY(elemento)
{
var y=0;
while(elemento)
{
y += elemento.offsetTop;
elemento=elemento.offsetParent;
}
return y;
}
It works great!, except when the div (elemento in my script) is inside
an absolute positioned div. I need to obtain the coordintes no matter
where in the DOM tree the div is.
Any ideas? Thanks