Home > Software engineering >  Auto-Scroll Fast in JS
Auto-Scroll Fast in JS

Time:11-07

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.

CodePudding user response:

These are the values which should work best in my opinion

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