Question

I'm looking for a way for javascript to tell how far a user has scrolled down the screen.

Instead of doing this through x, y coordinates is there a way to pull what's at the top of the viewport?

Either the text / line number or the current top element in the viewport?

Was it helpful?

Solution

No, you can't. You have to set scroll events and update x and y values. Then, with those values, you can get the element at this position. https://developer.mozilla.org/en/DOM/document.elementFromPoint http://msdn.microsoft.com/en-us/library/ms536417%28VS.85%29.aspx

OTHER TIPS

Have a look at jQuerys scrollTop()

This should probably do it for you:

$("body").scrollTop()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top