function offsetTop( elements ){
var top = elements.offsetTop; var parent = elements.offsetParent; while( parent != null ){ top += parent.offsetTop; parent = parent.offsetParent; }; return top; };function getTop(e){
var offset=e.offsetTop;
if(e.offsetParent!=null)
offset+=getTop(e.offsetParent);
return offset;
}
element.getBoundingClientRect() 获取元素距页面顶端距离。