I have this function that fires a click when the user is 500px from the bottom of the window.
It all works fine, except when I set my html and body to height:100% in the css.
Here's the 'working' script.
$(document).ready(function() {
var timeout = '';
$(window).scroll(function (e) {
var intBottomMargin = 500;
clearTimeout(timeout);
//if less than intBottomMargin px from bottom
if ($(window).scrollTop() >= $(document).height() - $(window).height() - intBottomMargin) {
timeout = setTimeout(function(){
$("#next-paginav")[0].click();
}, 300);
}
});
});
How do I make the same script work when my html and body are 100% height?
I'm sure it's really simple to do.