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.
Asked
Active
Viewed 77 times
-2
-
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 Answers
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