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

163
Views
window.history.back() won't take me back to homepage

I'm creating a website right now with multiple pages, that you access through the homepage however, each page has a back button that takes you back to the previous page, however the back button doesn't take me back to the homepage and will instead take me back to the page before that. I noticed that if I click once into a separate link from the homepage that new link will overwrite the homepage from my browser history. What is the explanation for this and what is the fix?

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

0

To go back to the home page, you can try the code below:

location.href = "/";
about 4 years ago · Juan Pablo Isaza Report

0

Tha is the expected behaviour as per MDN

The History.back() method causes the browser to move back one page in the session history. It has the same effect as calling history.go(-1). If there is no previous page, this method call does nothing.

To go back to the homepage, you can provide a static link to your website homepage, similar to www.example.com

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!