get page scroll position code example

Example 1: javascript get scroll position

function getYPosition(){
  var top  = window.pageYOffset || document.documentElement.scrollTop
  return top;
}

Example 2: get current scroll height javascript

document.documentElement.scrollTop || document.body.scrollTop

Example 3: window log scrollpostion

$(window).on('scroll', function() {
    console.log( $(this).scrollTop() );
});

Example 4: get current scroll height javascript

document.documentElement.scrollTop = document.body.scrollTop = 1000;