Posts with the tag JavaScript:

Vanilla JavaScript Update URL without Refresh

Today we are looking into updating the URL without doing a refresh. We can make use of the History API to access and modify the URL states. The cool part, it has superb browser support! JavaScript History API The history API is a set of methods used to manipulate history. For instance, we can go forward and backward, just like clicking the buttons in your browser. More on these methods in another article. JavaScript history.pushState Today’s focus is on the method called pushState(). We can use this method to push a new entry into the browser’s history. It doesn’t need a refresh and will show the new URL in the browser.