Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading