原理: body的offsetParent返回的是null。
/**
* Get element's absolute coordinate in body*/
window.getAbsCoordinates=function(e){
var pos = {top: 0, left: 0};
while(e){
pos.left += e.offsetLeft;
pos.top += e.offsetTop;
e=e.offsetParent;
}
return pos;
};
原理: body的offsetParent返回的是null。
/**
* Get element's absolute coordinate in body