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

168
Views
Using location.href on webpage is not saving the last page to history

So currently, I'm running this code on my webpage in order to detect where the user came from:

if (document.referrer == "https://firsturl.com/") {
  window.location.href = "https://secondurl.com/next"
} else if (document.referrer == "https://secondurl.com/") {
  location.replace("https://firsturl.com/specialpage")
}

but it isn't adding the first (original) page to history even though I am using location.href for the first redirect. Basically what I want the user to do is to click on a button, then click the back button, and then they'll be on a different page.

By the way, I would appreciate any solutions that don't require AJAX or JQuery.

about 4 years ago · Santiago Trujillo
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!