Sometimes, we want to remove hash from URL with JavaScript.
In this article, we’ll look at how to remove hash from URL with JavaScript.
How to remove hash from URL with JavaScript?
To remove hash from URL with JavaScript, we call the history.pushState method.
For instance, we write
history.pushState("", document.title, window.location.pathname);
to call pushState with '' and window.location.pathname to remove the hash from the URL.
Conclusion
To remove hash from URL with JavaScript, we call the history.pushState method.