Each html elements in a page has position values (ie. where the elements currentlyThe script follows. Argument of the function is the object of the HTML element,
placed). Basically it is measured by pixels from top and pixels from left.The top
and left position values are obtained by using the html elements attributs offsetTop
and offsetLeft.This can be calculated at run time using javascrit.
and it returns the array of values.
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
No comments:
Post a Comment