js控制滚动条自动往下滑动

function() {
    var height = document.body.clientHeight;
    var number = 0; //控制结束累加器
    var length = 0; //控制每次翻滚长度
    var frequency = 5; //控制总时间
    var time = setInterval(function(){
    number += 1;
    if(number == frequency + 1){
        clearInterval(time);
    } else {
        length += height / frequency;
        document.documentElement.scrollTop = length;
    }
    },500); //每隔500MS翻滚一次
}        

  参考https://blog.csdn.net/weixin_42342572/article/details/82385590 效果不错

posted @ 2021-03-16 18:15  kakaok  阅读(3075)  评论(0编辑  收藏  举报