var a=5; var b=300; var n = 5; function fn() { a += 1; b += 100; window.scrollTo(a,b); n--; if(n > 0) window.setTimeout(fn, 30 * 1000) } window.setTimeout(fn, 30 * 1000);