/** * @return [x,y] - position of the upper-left corner of node relativ to the * upper-left corner of the page */ function getPageRelativePosition(node) { var result = [0,0]; while (node) { result[0] += (node.offsetLeft - node.scrollLeft); result[1] += (node.offsetTop - node.scrollTop); node = node.offsetParent; } return result; }