How do I modify the URL without reloading the page?
Asked 07 September, 2021
Viewed 1.5K times
  • 55
Votes

Is there a way I can modify the URL of the current page without reloading the page?

I would like to access the portion before the # hash if possible.

I only need to change the portion after the domain, so it's not like I'm violating cross-domain policies.

 window.location.href = "www.mysite.com/page2.php";  // Sadly this reloads

20 Answer