【摘要】获得HTML元素的绝对位置

function findAbsolutePosition(obj) { var curleft = curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); } return [curleft,curtop]; //returns an array }


原文地址:http://vikku.info/codesnippets/javascript/find-absolute-position-of-an-html-element/

你可能感兴趣的:(html)