js实现页面自动滚动

81 阅读1分钟
let a = 100;
function zidingyi() {
    a = a+200
    window.scrollTo(0,a)
}
setInterval(() => {
    zidingyi()
},1000)

// 获取整个页面的高度
const pageHeight = Math.max(
  document.documentElement.scrollHeight,
  document.body.scrollHeight
);

console.log(`页面的高度: ${pageHeight}px`);