200高分~~~求“回顶部”浮动代码!

来源:百度知道 编辑:UC知道 时间:2024/06/07 17:05:46
如题:求“回顶部”浮动代码!

演示一:http://www.lunuo.cc/ (右下角)
演示二:http://item.taobao.com/auction/item_detail-0db0-6e895e5c32edd1608cd4817dbab3a746.jhtml?is_b=1 (右下角,往下滚动才显示)

谢谢!

下面是代码,试试看

<div style="height:1000px"></div>
<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:15px;POSITION:absolute;TOP:150px;z-index:100'><a href='#Top'><img src=http://www.lunuo.cc/imag