I have searched about this topic and all solutions that I got is based on time intervals. I have a php page which is based on a query. The results of this query can be small or huge depending on its parameters. The generated page must be scrolled down smoothly until the results end and scrolled top again and repeat. If the solution is based on time interval, the page can be scrolled and the results can not be shown completely.
One of the solutions, based on time intervals, that I got is this: Autoscroll to bottom of page then top and repeat. I am ttrying using javascript or jquery, using the code below:
<script>
var pix = 0;
var sh = document.body.scrollHeight;
var ch = document.body.clientHeight;
setInterval(function(){
pix = pix+1;
//console.log("sh="+sh+" ch="+ch+ " pix="+pix);
if (pix<=sh)
window.scrollBy(0, 10);
else {
pix = 0;
$(document.body).scrollTop(0);
}
}, 1000);
</script>
The first part is ok: the scroll goes smoothly. But when the page gets the end, it did not start again ($(document.body).scrollTop(0);
)
Best regards, thanks.