获取元素到body的距离:
<script> function offsetDis(obj) { var l = 0, t = 0; while(obj) { l = l + obj.offsetLeft + obj.clientLeft; t = t + obj.offsetTop + obj.clientTop; obj = obj.offsetParent; } return {left: l, top: t}; } </script>