var bdy = (document.documentElement && document.documentElement.clientWidth)?document.documentElement:document.body; var topPx = 80;//距离顶部的距离 //页面加载 function myload() { document.getElementById("ecbox").style.top=bdy.scrollTop+topPx; move(); } //滚动 function move() { document.getElementById("ecbox").style.top=bdy.scrollTop+topPx; setTimeout("move();",50); } myload();