Hi all I have little javascript experience so I'm totally lost on this. I've written a script that scrolls to the bottom of the page and jumps back to the top once it reaches the bottom. That part works, but now the cleint want to have a pause / resume action on the scrolling and I'm stumped. Here's the script (if you would like to see more of the code just let me know): function clicked() { if (pause != 1) { pause = 1; pauser(); } else { pause = 0; pageScroll(); } } function pauser() { window.status='paused'; window.scrollTo(0,x); } function starter() { pause = 0; y = document.getElementById('maintbl').offsetHeight; x = window.innerHeight; pageScroll(); } function pageScroll() { window.scrollBy(0,50); scrolldelay = setTimeout('pageScroll()',7000); // scrolls every 1000 milliseconds x = x+50; if (x > y){ window.scrollTo(0,0); x = 0; location.reload; } } Code (markup): in the html I use: onload = "pageScroll()" onclick = "clicked()" Code (markup): Thanks to anyone who could give me a tip on any of this.
Try: var pause; var scrollDelay; function clicked() { if (pause != 1){pause = 1;pauser();} else {pause = 0;pageScroll();} } function pauser() { window.status='paused'; window.scrollTo(0,x); clearInterval(scrollDelay); } function starter() { pause = 0; y = document.getElementById('maintbl').offsetHeight; x = window.innerHeight; pageScroll(); } function pageScroll() { window.scrollBy(0,50); scrolldelay = setInterval('pageScroll()',7000); // scrolls every 1000 milliseconds x = x+50; if (x > y){ window.scrollTo(0,0); x = 0; location.reload; } } Code (markup):