Is it possible to fire an alert after a user scrolls 100 pixels.
Here’s what I have so far but I know I’m missing something;
$(window).scroll(function() {
if (document.documentElement.clientHeight +
$(document).scrollTop() == "100px")
{
alert("You've scrolled 100 pixels.");
}
});
Look at the window .scrollTop (returns an integer):
but if you have scrolled 102px it wont trigger the alert box.
if you just want to trigger the alert once have a global variable that sets to true if it has been trigged:
or just unbind the scroll event once the alert box has been trigged: