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?

有帮助吗?

解决方案

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

其他提示

Have a look at jQuerys scrollTop()

This should probably do it for you:

$("body").scrollTop()
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top