What is the easiest way to check if the window scroll is at the bottom—without using jQuery
?
I've come across some methods, but most of them don't work cross browser.
What is the easiest way to check if the window scroll is at the bottom—without using jQuery
?
I've come across some methods, but most of them don't work cross browser.
Here is one technique that works across a handful of browsers I tested
window.onscroll = function () {
var totalHeight = document.documentElement.scrollHeight;
var clientHeight = document.documentElement.clientHeight;
var scrollTop = (document.body && document.body.scrollTop)
? document.body.scrollTop : document.documentElement.scrollTop;
if (totalHeight == scrollTop + clientHeight)
console.log('Bottom');
}