0 votes
in JavaScript by
How do I modify the url without reloading the page?

1 Answer

0 votes
by

The window.location.href property will be helpful to modify the url but it reloads the page. HTML5 introduced the history.pushState() and history.replaceState() methods, which allow you to add and modify history entries, respectively. For example, you can use pushState as below,

window.history.pushState("page2", "Title", "/page2.html");
...