How to remove the hash from window.location (URL) with JavaScript without page refresh?


You can use the replaceState method on the history API to remove the hash.

The replaceState() method modifies the current history entry, replacing it with the state objects, title, and URL passed in the method parameters. This method is particularly useful when you want to update the state object or URL of the current history entry in response to some user action.

To remove the hash you can use −

history.replaceState(null, null, ' ');
raja
Published on 02-Dec-2019 05:32:43
Advertisements