-2

In JavaScript/jQuery, how do I determine how far the top of my current screen is from the very top of the document? I don't want to measure from a specific element. I'm working on an infinite scroll page.

Tom
  • 1,215
  • 3
  • 19
  • 30
  • Store a variable named `scroll` and on every scroll event change this variable ? Did you try this? – XCS Jul 28 '16 at 14:47

1 Answers1

1

The way you do it differs between most browsers and IE. This should work for all browsers:

var scrollPos = window.scrollY || window.pageYOffset;
Jacob
  • 77,566
  • 24
  • 149
  • 228