Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chrome 版本61之后 $('body').scrollTop() 会获取到0 #12

Open
aototo opened this issue Oct 12, 2017 · 4 comments
Open

chrome 版本61之后 $('body').scrollTop() 会获取到0 #12

aototo opened this issue Oct 12, 2017 · 4 comments

Comments

@aototo
Copy link
Owner

aototo commented Oct 12, 2017

如果使用$('body').scrollTop() 获取的值是0,谷歌Translate翻译插件就是这样失效的。
使用documentElement || body 来兼容。

let scrollTop = document.documentElement.scrollTop || document.body.scrollTop

或者使用

$(window).scrollTop()

之前使用$('body').scrollTop() 的插件,需要修改了

@lijiahao8898
Copy link

今天刚改了这么个问题。

@ygl1992
Copy link

ygl1992 commented Oct 13, 2017

昨天那纳闷呢,之前是没问题。感谢提醒

@isoloist
Copy link

isoloist commented Nov 8, 2017

Thanks

@zty327106366
Copy link

为什么不用 window.pageYOffset 呢

Repository owner deleted a comment from daino0 Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants