How do I modify the following script to be able to stop and enable auto-scrolling using a simple text link like this html link
<a href="javascript:stopScroll()">Stop Scrolling</a>
?
Thanks.
<script>
(function() {
'use strict';
var dbh,sto,num=3,temp=0,scrolldelay=70;
function init(){
dbh=document.body.offsetHeight;
pageScroll();
}
function pageScroll() {
window.scrollBy(0,num);
temp+=num;
if((temp>=dbh)||(temp<=0)){
num=-num;
}
sto=setTimeout(function(){pageScroll();},scrolldelay);
}
window.addEventListener?
window.addEventListener('load',init,false):
window.attachEvent('onload',init);
})();
</script>