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

275
Views
window.location.href works offline but anchor tag does not

I am building a progressive web app (PWA) that is usable offline.

On the page, I use the link to navigate back to the previous page like this.

<a href="/alink">Back<a>

It doesn't work but causes the No Internet.

On the other hand, the window.location.href does navigate to the previous page even when I'm offline.

Why does this happen? What is the difference between a tag and window.location.href?

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

0

The a tag will redirect to the new page by going forward to it.
However the window.location.href will just change the route in the URL. But not actually redirect the page.

If you want to go back, try using the window history. As this is what things like react router use to move around different paths.

https://developer.mozilla.org/en-US/docs/Web/API/Window/history

Hope this helps.

about 4 years ago · Juan Pablo Isaza Report

0

The a tag always redirects you to a new page which is required a network connection. If you want to get back to the previous page with the a tag. You can use this

<a href="javascript:history.back()">Back</a>

It will navigate you back to the cached page that you loaded before going offline.

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!