simple way to determine if the user has scrolled on a page
Here is a simple way to determine if the user has scrolled down on a page or not.
The closure is bound to the scroll event, so everytime a user scrolls the page, it will be evaluated if the user is on position 0 of the page (meaning, on top of the page) or not.
If so, isOnTop will be set to true. This can be used to give the body or other elements on the page certain css classes in order to give them different styles depending on the position of the page.
This example uses jQuery.
var isOnTop = ($(window).scrollTop() == 0);
console.log('Beginning of page: ' + isOnTop);