change href without reloading page js

Solutions on MaxInterview for change href without reloading page js by the best coders in the world

showing results for - "change href without reloading page js"
Mayron
27 May 2017
1// Current URL: https://my-website.com/page_a
2const nextURL = 'https://my-website.com/page_b';
3const nextTitle = 'My new page title';
4const nextState = { additionalInformation: 'Updated the URL with JS' };
5
6// This will create a new entry in the browser's history, without reloading
7window.history.pushState(nextState, nextTitle, nextURL);
8
9// This will replace the current entry in the browser's history, without reloading
10window.history.replaceState(nextState, nextTitle, nextURL)