Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
How to jump to top of page when routing WITHOUT using scroll?

I'm building a React application where I have footer links that when clicked, take the user to the bottom of whatever page they're clicking. I want to change it so that when these links are clicked, the user is automatically taken to the top of the new page.

I already tried a solution of automatically scrolling to the top of the page, which WORKS, but the issue is that I have smooth scrolling set for my website because I have some buttons that scroll to certain parts of the page clicked, and I want that animation to be smooth. However, for this particular function, I don't want smooth scroll because I don't want the user to see that they were taken to the bottom of a page then scrolled up.

This is my current code:

useEffect(() => {
    window.scrollTo(0, 0)
}, [])

Is there any way I can accomplish this without using scroll so that I can avoid having to display the smooth scrolling behavior?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can try adding behaviour as instant in scrollTo function and do let me know if it works

useEffect(() => {
     window.scrollTo({
      top: 0,
      left: 0,
      behavior: "instant"
    });
}, [])
about 4 years ago · Juan Pablo Isaza Report

0

window.scrollTo({
  top: 0,
  left: 0,
  behavior: 'auto'
});

Should hopefully remove the smooth action.

about 4 years ago · Juan Pablo Isaza Report

0

document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera

document.body.scrollTop = 0; // For Safari
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!