<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <style>


h1{
height:500px;

}



  </style>

</head>
<body>
  
  



<h1>哈哈哈</h1>
<h1>哈哈哈</h1>
<h1>哈哈哈</h1>
<h1>哈哈哈</h1>
<h1>哈哈哈</h1>











<script>




function debounce(fn,delay){
  var timer = null;

  return function(){


    if(timer){
      clearTimeout(timer)
    }

    timer = setTimeout(fn,delay)


  }
}










//滚动事件
window.onscroll = debounce(scrollHandle,200)




function scrollHandle(){

  console.log("页面滚动了,高度为:");

var scrollTop = document.documentElement.scrollTop;

console.log(scrollTop);


};










</script>







</body>
</html>