当内容到达其结尾时刷新内容" div"

时间:2016-09-15 09:22:20

标签: jquery ajax jquery-animate

我希望我的页面在自动向下滚动后自动刷新...这里是关于如何自动向上和向下滚动的代码。

app.controller('MainController', function($scope){
$scope.message = "Hello";
});

1 个答案:

答案 0 :(得分:1)

这是一个快速的小提琴:https://jsfiddle.net/manoeuvres/LbLaf8La/在第二个动画调用的“动作完成”功能中添加了刷新调用location.reload();,因此当动画返回到顶部时它会刷新。

function scroll(speed) {
$('html, body').animate({ scrollTop: $(document).height() }, speed, function() {
    $(this).animate({ scrollTop: 0 }, speed, function(){ location.reload(); });
});
}

speed = 25000;

scroll(speed)
setInterval(function(){scroll(speed)}, speed * 2); // because the page is refreshing I don't think this line gets to get called. but no problem to leave it in.
相关问题