亲宝软件园·资讯

展开

js动态移动滚动条至底部示例代码

人气:0
复制代码 代码如下:

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);
}
}

加载全部内容

相关教程
猜你喜欢
用户评论