javascript get scroll position

JavaScript
function getYPosition(){
  var top  = window.pageYOffset || document.documentElement.scrollTop
  return top;
}$(window).on('scroll', function() {
    console.log( $(this).scrollTop() );
});$(window).scroll(function() {
	var $height = $(window).scrollTop();
  if($height > 50) {
		//do something
	} else {
		//do something
	}
});
Source

Also in JavaScript: