In Google chrome document.body.scrollTop always returns 0.
I try
if (window.pageYOffset > 0) {
st = window.pageYOffset;
} else if (document.documentElement.scrollTop > 0) {
st = document.documentElement.scrollTop;
} else {
st = document.body.scrollTop;
}
But not working. document.body.scrollTop is working in firefox.
Even in chrome console when i this code in console it is not working.
enter code here
$('html, body').stop().animate({
scrollTop: 50
}, 500);
I hit this as well. According to this issue this behavior changed between Chrome 60 and Chrome 61:
https://bugs.chromium.org/p/chromium/issues/detail?id=766938
From what I have read the new behavior is actually more standards compliant. The suggested fix from comment #5 for that issue is: