js動態(tài)移動滾動條至底部示例代碼
更新時間:2014年04月24日 17:44:24 作者:
這篇文章主要介紹了使用js動態(tài)移動滾動條至底部,需要的朋友可以參考下
復(fù)制代碼 代碼如下:
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);
}
}
相關(guān)文章
javascript break指定標(biāo)簽打破多層循環(huán)示例
break的語法有兩種break; 和 break label;下面為大家介紹下直接break掉整個循環(huán)嵌套示例2014-01-01
js獲取json中key所對應(yīng)的value值的簡單方法
下面小編就為大家?guī)硪黄猨s獲取json中key所對應(yīng)的value值的簡單方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-03-03

