A
Amir Hardon
I'm sorry for the RTFM question, but these keywords are too
common for being usefull with google.
I'm trying to position a dynamically created DOM element
(with style.position=absolute), in a position relative to
another element which don't have an absolute position,
My problem is getting the "absolute" position of that element.
I wrote two function(below) to solve this problem,
but I'm pretty sure there is a more effective solution:
function getoffsetLeft(element){/* Calculate the offsetLeft sum of all
offsetParents.
The result is element.style.left
*/
if(!element) return 0;
return element.offsetLeft + getoffsetLeft(element.offsetParent);
}
function getoffsetTop(element){/* Calculate the offsetTop sum of all
offsetParents.
The result is element.style.top
*/
if(!element) return 0;
return element.offsetTop + getoffsetTop(element.offsetParent);
}
common for being usefull with google.
I'm trying to position a dynamically created DOM element
(with style.position=absolute), in a position relative to
another element which don't have an absolute position,
My problem is getting the "absolute" position of that element.
I wrote two function(below) to solve this problem,
but I'm pretty sure there is a more effective solution:
function getoffsetLeft(element){/* Calculate the offsetLeft sum of all
offsetParents.
The result is element.style.left
*/
if(!element) return 0;
return element.offsetLeft + getoffsetLeft(element.offsetParent);
}
function getoffsetTop(element){/* Calculate the offsetTop sum of all
offsetParents.
The result is element.style.top
*/
if(!element) return 0;
return element.offsetTop + getoffsetTop(element.offsetParent);
}