/**
* @description 获取滚动条滑动的距离
* document.documentElement.scrollTop | document.body.scrollTop
* document.documentElement.scrollLeft | document.body.scrollLeft
* IE8 和 IE8 以下的浏览器不兼容
* window.pageYOffset
* window.pageXOffset
* @returns {x:0,y:0}
*/
function getScrollOffset(){
if(window.pageXOffset){
return {
x: window.pageXOffset,
y:window.pageYOffset
}
}else{
return {
x: document.body.scrollLeft + document.documentElement.scrollLeft,
y: document.body.scrollTop + document.documentElement.scrollTop,
}
}
}

相关文章:

  • 2018-03-08
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-11-17
  • 2022-01-02
  • 2022-12-23
相关资源
相似解决方案