自动从顶部滚动页面到底部,然后备份(和重复) [英] Automatically Scroll Page from Top to Bottom, then Back Up (and Repeat)

查看:219
本文介绍了自动从顶部滚动页面到底部,然后备份(和重复)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图弄清楚如何在页面加载时自动滚动到页面的底部(已经充分描述了,然后在到达页面底部时自动向上滚动。我可以找到自动滚动到底部,但我无法弄清楚当我在页面底部时如何识别,以及如何在我的时候向上滚动。我会使用通用的Javascript(或JQuery)来做这件事。

I'm trying to figure out how to, upon pageload, automatically scroll to the bottom of a page (which has been described sufficiently here) and then scroll back up automatically upon reaching the bottom of the page. I can find the automatic scrolling to the bottom, but I can't figure out how to identify when I'm at the bottom of the page, and how to scroll back up when I am. I'd do this using generic Javascript (or JQuery).

提前致谢!

推荐答案

试试这个:
http://jsfiddle.net/yjYJ4/

$('html, body').animate({ scrollTop: $(document).height() - $(window).height() }, 1000, function() {
    $(this).animate({ scrollTop: 0 }, 1000);
});

您可以在此处全屏查看演示: http://jsfiddle.net/yjYJ4/embedded/result/

You can view the demo in full screen here: http://jsfiddle.net/yjYJ4/embedded/result/

更改数字1000如果你想增加或减少速度。

Change the number "1000" if you want to increase or decrease speed.

适用于Chrome,Firefox和IE 6-9。

Works fine in Chrome, Firefox and IE 6-9.

编辑:

如果你需要它永远重复(不推荐......)你可以这样做: http://jsfiddle.net/QUCWe/

If you need it to repeat forever (not recommended...) you could do like this: http://jsfiddle.net/QUCWe/

这篇关于自动从顶部滚动页面到底部,然后备份(和重复)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆