简体   繁体   English

为什么 body.scrollTop 不适用于 Google chrome 和 Firefox,但适用于 Microsoft Edge

[英]Why body.scrollTop is not working on Google chrome and Firefox but working on Microsoft edge

Previously body.scrollTop was working in my chrome.....but suddenly body.scrollTop is returning 0 in firefox and chrome......but returning proper value in Microsoft edge..以前body.scrollTop在我的 chrome 中工作......但突然body.scrollTop在 firefox 和 chrome 中返回 0......但在 Microsoft Edge 中返回正确的值......

can anyone help me out?谁能帮我吗?

Use document.documentElement.scrollTop to return scroll position value使用document.documentElement.scrollTop返回滚动位置值

Update: Use both更新:同时使用

var value = document.body.scrollTop || document.documentElement.scrollTop;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Blogger中时,body.scrollTop在Firefox和IE中不起作用 - body.scrollTop is not working in firefox and IE When inside Blogger 为什么不推荐使用 body.scrollTop? - Why is body.scrollTop deprecated? window.top.document.body.scrollTop 在 Chrome 或 FireFox 中不起作用 - window.top.document.body.scrollTop not working in Chrome or FireFox javascript.bind() 不适用于 microsoft edge 和 Google chrome - javascript .bind() is Not working on microsoft edge and Google chrome Web通知无法在chrome上运行,但在Firefox和Microsoft Edge上可以正常运行 - Web notifications is not working on chrome, but it's working fine on firefox and microsoft edge 为什么标头转换在chrome和firefox中有效,但在edge中却无效? - Why is header transition working in chrome and firefox, but not in edge? XPath选择在Microsoft Edge中不起作用(适用于Chrome和Firefox) - XPath selection not working in Microsoft Edge (works in Chrome and Firefox) $('html body')。animate({scrollTop:在Firefox中不起作用 - $('html body').animate({ scrollTop: not working in Firefox jQuery scrollTop() 不适用于 Firefox 中的“body”元素 - jQuery scrollTop() not working on 'body' element in Firefox ScrollTop可在Chrome和Edge中使用,但不能在Firefox中使用 - ScrollTop works in Chrome and Edge but not Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM