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

177
Views
How to keep the state using history.replaceState?

I try to use the window.history.replaceState method just to show the URL shown in the browser.

window.history.replaceState("","","newurl.php");

Well, this works well and changes the URL. But what is this "State" that I set to "" here? And how should I change my code if I simply want to be the State as before? (As I said... I just wanted to change the URL and this works well, not to change the state...)

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

0

.replaceState() a way to associate some data (any data that can be structured cloned) with the current location - without reloading the page. There's also pushState, that does the same thing, but you can also use the browser's back button to go back to the previous displayed url / state.

If you don't use these for something else, you don't have to care about the state you set (it's only visible to your website).

If you, on the other hand, do use states, and don't want to change it, you can set the same state as it was before. You can get the current state with history.state:

window.history.replaceState(window.history.state,"","newurl.php");
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!