I have a page that begins to scroll automatically when the user begins to scroll the scrollbar. But I want the scrolling to stop after a certain amount of time. Below is what I have so far but it is not working. I don' think that "return;" is the right function I should be using but I can't find anything that does work.
function scrollFunction() {
window.scrollBy(0, 10);
}
window.onscroll = scrollFunction;
setTimeout(function scrollFunction() {
return;
}, 2000);
<div style="height:1000px; background-color:red;"></div>
<div style="height:1000px; background-color:green;"></div>
<div style="height:1000px; background-color:blue;"></div>
<div style="height:1000px; background-color:black;"></div>