I either dreamt about chrome (dev channel) implementing a way to update the address bar via javascript (the path, not domain) without reloading the page or they really have done this.
However, I can't find the article I think I read.
Am I crazy or is there a way to do this (in Chrome)?
p.s. I'm not talking about window.location.hash, et al. If the above exists the answer to this question will be untrue.
Method 2: Adding a new state with pushState() Method: The pushState() method is used to add a new history entry with the properties passed as parameters. This will change the current URL to the new state given without reloading the page.
HTML5 History API allows browsers to change the URL in browser address bar without reloading or refreshing the page using pushState function. The pushState method works similar to window.
You can now do this in most "modern" browsers!
Here is the original article I read (posted July 10, 2010): HTML5: Changing the browser-URL without refreshing page.
For a more in-depth look into pushState/replaceState/popstate (aka the HTML5 History API) see the MDN docs.
TL;DR, you can do this:
window.history.pushState("object or string", "Title", "/new-url");
See my answer to Modify the URL without reloading the page for a basic how-to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With