Frage

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?

War es hilfreich?

Lösung

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

Andere Tipps

Have a look at jQuerys scrollTop()

This should probably do it for you:

$("body").scrollTop()
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top