获取到body的offsetTop和offsetLeft值

function offsetTL(obj){//获取到body的offsetTop和offsetLeft
var t=0,l=0;
while(obj){
t=t+obj.offsetTop;
l=l+obj.offsetLeft;
obj=obj.offsetParent;
}
return {top:t,left:l};
}

原文地址:https://www.cnblogs.com/wbxjiayou/p/5298908.html