setInterval(function() {
window.scrollTo(0, document.body.scrollTop + 5)
}, 60) setInterval(function() {
window.scrollTo(0, document.body.scrollTop + 5)
}, 60)Try this one instead to see the difference. This will scroll at approximately the same rate as your example:
setInterval(function() { window.scrollTo(0, document.body.scrollTop + 1) }, 12);
I prefer it a bit slower though:
setInterval(function() { window.scrollTo(0, document.body.scrollTop + 1) }, 30);
javascript:setInterval(function() { window.scrollTo(0, document.body.scrollTop + 1) }, 30);
On Chrome 39 on CrOS, I can't type that into the URL field, and if I copy/paste it, the "javascript:" portion of the scheme magically disappears, so hitting enter takes me to a SERP. I wonder if that's done in the hope that you Google the self-XSS that you were about to run and see someone explain what's going on.
Isn't this how everyone scrolls slowly?
setInterval(function () { window.scrollTo(0, document.documentElement.scrollTop + 5); }, 60)
do this instead for 60 intervals per second: setInterval(function() { window.scrollTo(0, document.body.scrollTop + 5) }, 16.666666666666668)
or better yet skip the setInterval and have the page continue to move:
var scrollIncrement = 5;
var height = Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight ) - window.innerHeight;
var AnimationFrame = (function() {
var FPS = 16.6666666667; // 1000 / 60 = Frames Per Second
var RAF = window.requestAnimationFrame
|| window.webkitRequestAnimationFrame
|| window.mozRequestAnimationFrame
|| window.msRequestAnimationFrame
|| window.oRequestAnimationFrame
|| function(a) { window.setTimeout(a, FPS); }
var CAF = window.cancelAnimationFrame
|| window.webkitCancelAnimationFrame
|| window.mozCancelAnimationFrame
|| window.msCancelAnimationFrame
|| window.oCancelAnimationFrame
|| function(a) { window.clearTimeout(a); }
return {
request: function(a) {
RAF(a);
},
cancel: function(a) {
CAF(a);
}
}
})();
var scroll = function(){
var scrollPosition = Math.max( document.documentElement.scrollTop, document.body.scrollTop );
if ( scrollPosition == height )
scrollIncrement = (-1 * scrollIncrement);
else if ( scrollPosition == 0 )
scrollIncrement = (-1 * scrollIncrement);
window.scrollBy(0, scrollIncrement);
AnimationFrame.request(scroll);
}
AnimationFrame.request(scroll);
you can easily just tweak the scroll distance as well by entering scrollIncrement = x;