返回顶部js

<script language=javascript>
lastScrollY=0;
function heartBeat(){
var diffY;
if (document.documentElement && document.documentElement.scrollTop)
   diffY = document.documentElement.scrollTop;
else if (document.body)
   diffY = document.body.scrollTop;
else
{/*Netscape stuff*/}
 
//alert(diffY);
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("web_ad").style.top=parseInt(document.getElementById("web_ad").style.top)+percent+"px";
lastScrollY=lastScrollY+percent;
//alert(lastScrollY);
}
suspendcode="<DIV id="web_ad" style='right:5px;POSITION:absolute;TOP:330px; border:0px solid #ddd;'><a href='javascript:scroll(0,0)'><img border=0 src='up.gif' alt='返回顶部' /></a></div>";
document.write(suspendcode);

window.setInterval("heartBeat()",1);

</script>
<div style="height:2000px"></div>

    A+
发布日期:2009年07月20日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: