您的位置:首页 > Web前端 > JavaScript

js动态移动滚动条至底部

2014-04-24 16:00 211 查看
var currentPosition,timer;

function GoBottom(){

timer=setInterval("runToBottom()",50);

}

function runToBottom(){

currentPosition=document.documentElement.scrollTop || document.body.scrollTop;

currentPosition+=30;

if(currentPosition<document.body.scrollHeight && (document.body.clientHeight + document.body.scrollTop < document.body.scrollHeight))

{

//window.scrollTo(0,currentPosition);

//alert(document.documentElement.clientHeight + " " + document.documentElement.scrollTop + " " + document.documentElement.scrollHeight + "#" +document.body.clientHeight + " " + document.body.scrollTop + " " + document.body.scrollHeight);

document.body.scrollTop = currentPosition;

}

else

{

document.body.scrollTop = document.body.scrollHeight;

clearInterval(timer);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  js 动态移动 滚动条