Distances window.pageYOffset Get the distance the user has scrolled from the top of the page. var distance = window.pageYOffset;