0

I have a page that does infinite scrolling and I wanted to do some performance testing on it by scrolling endlessly to the bottom of the page.

Is there a jQuery/javascript command that allows me to scroll continously on a page non-stop?

I tried doing the following:

   for (var i=0;i<100;i++)
{ 
    setTimeout(window.scrollTo(0,document.body.scrollHeight), i * 10000);
}

basically I wanted to call window.scrollTo .. after delayed for 5 seconds, and then calling it again.. infinitely. However the solution above doesn't work. I don't care about this being hacky, I just needed something to work for testing.

4

2 回答 2

0

这是一个简单的小提琴

CSS:

body{
    height:400px;
    overflow-y:scroll;
}

JS:

var body = $('body');
setInterval(function(){
    var pos = div.scrollTop();
    div.scrollTop(pos + n);  // you can have your offset
}, 200);
于 2013-08-01T04:05:15.907 回答
0

你可以这样做

$("html, body").animate({ scrollTop: $(document).height() }, "slow");
于 2013-08-01T04:10:46.067 回答