Home  >  Article  >  Web Front-end  >  js dynamically move the scroll bar to the bottom sample code_javascript skills

js dynamically move the scroll bar to the bottom sample code_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:51:151133browse
复制代码 代码如下:

var currentPosition,timer;
function GoBottom(){
timer=setInterval("runToBottom()",50);
}
function runToBottom(){
currentPosition=document.documentElement.scrollTop || document.body.scrollTop;
currentPosition =30;
if(currentPosition{
//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);
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn