为窗口添加滚动条事件其实非常的简单,

window.onscroll=function(){};
注意在获取滚动条距离的时候
谷歌不识别document.documentElement.scrollTop,必须要加上document.body.scrollTop;即
var scrolltop=document.documentElement.scrollTop||document.body.scrollTop;
这样才能兼容各个浏览器!
 
var scrollTop = window.pageYOffset|| document.documentElement.scrollTop || document.body.scrollTop;

相关文章:

  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2021-04-04
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2021-07-01
相关资源
相似解决方案