关闭

jquery 返回顶部

202人阅读 评论(0) 收藏 举报

var speed=10
var currentpos=0,alt=1,curpos1=0,curpos2=-1
function initialize(){
startit()
}
function scrollwindow(){

if (document.all)
temp=document.documentElement.scrollTop
else
temp=window.pageYOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
currentpos=document.documentElement.scrollTop-speed
else
currentpos=window.pageYOffset-speed
window.scroll(0,currentpos)
}
else{
currentpos=0
window.scroll(0,currentpos)
}
if(document.documentElement.scrollTop<5)

window.clearInterval(intervalID);
}
}
function startit(){

intervalID=setInterval("scrollwindow()",5)
}
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("scrollfull").style.top=parseInt(document.getElementById("scrollfull").style.top)+percent+"px";

lastScrollY=lastScrollY+percent;
}

suspendcode = '<div id="scrollfull" style="position:absolute; right:100px; top:500px;"><a href="javascript:window.scroll(0,0)" onfocus="blur()"><img src="../images/returnTop.png"  alt=""/></a></div>';
document.write(suspendcode);
window.setInterval("heartBeat()",10);

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:151256次
    • 积分:2430
    • 等级:
    • 排名:第15826名
    • 原创:105篇
    • 转载:9篇
    • 译文:0篇
    • 评论:17条
    最新评论