当前位置: 代码迷 >> Web前端 >> 回到网页top部分
  详细解决方案

回到网页top部分

热度:177   发布时间:2012-10-25 10:58:57.0
返回网页top部分
<SCRIPT> 
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*/} 
percent=.1*(diffY-lastScrollY); 
if(percent>0)percent=Math.ceil(percent); 
else percent=Math.floor(percent); 
document.getElementById("full").style.top=parseInt(document.getElementById("full").style.top)+percent+"px"; 
lastScrollY=lastScrollY+percent; 
} 
suspendcode="<div id=\"full\" style='right:50px;POSITION:absolute;TOP:450px;z-index:100'><a href='#Top'><img src=images/top.gif border=0 alt='返回顶部'></a><br></div>" 
document.write(suspendcode); 
window.setInterval("heartBeat()",1);

?

1 楼 thunderbow 2010-07-14  
http://www.kunlun2000.com/zycp.htm样子地址
  相关解决方案