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)文章
簡單實用的js調(diào)試logger組件實現(xiàn)代碼
開發(fā)js組件的時間調(diào)試總是麻煩的,最常用的就是用alert或者debugger來測試js的運(yùn)行狀態(tài)。2010-11-11