Answer the question
In order to leave comments, you need to log in
Fix document.document.body.scrollTop issue?
How can the problem of document.body.scrollTop and document.documentElement.scrollTop be solved?
Of course, you can create a variable and assign Math.max( document.body.scrollTop, document.documentElement.scrollTop ) to it, only if, for example, the header has a navigation in which, when you click on the link, the page scrolls to the desired section, and in any case, at least document .body.scrollTop, even though document.documentElement.scrollTop is still equal to 0(. You can of course use hashes, but in my case a hash is not needed.
How can I get around this? Preferably without jquery and the like, I want to know how such moments can be solved.
Answer the question
In order to leave comments, you need to log in
Are you talking about errors in Opera, Chrome and Safari?
If yes, then there is no need to use them document.body.scrollTop
, you can simply refer to window.pageYOffset
. But where this property is not present, it works anywaydocument.documentElement.scrollTop
var cur_y = "pageYOffset" in window ?
window.pageYOffset : document.documentElement.scrollTop;
pageYOffset
cannot be changed, then there are methods scrollTo
and scrollBy
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question