Search code examples
javascripthtmlscroll

Auto-Scroll Fast in JS


I have a HTML which is very long. I would like to auto-scroll the content on load. My requirements are:

  1. Go to top when page opened.
  2. Scroll to the utmost bottom.

Here's what I tried:

function pageScroll() {
  window.scrollBy(0,7000);
  scrolldelay = setTimeout('pageScroll()',1000);
}

This works well but I want it to be faster and also I would like a replacement of 7000.


Solution

  • These are the values which should work best in my opinion

    function pageScroll() {
        window.scrollBy(0, 3060) //don't set a timeout function
    }
    pageScroll()