开发者

How to display a very long page like dzone.com?

If you ever visit dzone.com you'll notice that all the posts appear on 1 page only. When we scroll that page down, older posts will be added to the end of the page (and maybe some posts at the beginning of the page but outside the view port will be removed).

My questions are: - how to know if the user scrolls down/up开发者_StackOverflow with javascript/jQuery? - how to know if the user is at the top of the page (they click Ctrl + Home)?

Thank you.


You need to handle the scroll event and load more data using AJAX.


Scott Hanselman has a blog post about it: Infinite Scroll WebSites via AutoPagerize - Hacky, but the beginning of something cool


Use AJAX to load more content when the scroll position is near the bottom of the page.

Check out how Slashdot does it.


You could do it several ways, the idea is to load content lazily. There is a short tutorial with one possible solution here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜