获取浏览器滚动距离
文章目录
1 /**
2 * 获取浏览器滚动距离
3 */
4 function getScrollOffset() {
5 if (window.pageXOffset) {
6 return {
7 x: window.pageXOffset,
8 y: window.pageYOffset
9 }
10 } else {
11 return {
12 x: document.body.scrollLeft + document.documentElement.scrollLeft,
13 y: document.body.scrollTop + document.documentElement.scrollTop
14 }
15 }
16 }
17 console.log(getScrollOffset());
18
转载于猿2048:▶《获取浏览器滚动距离》
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论