update url parameters and create history entry

Solutions on MaxInterview for update url parameters and create history entry by the best coders in the world

showing results for - "update url parameters and create history entry"
Greta
30 May 2017
1// Construct URLSearchParams object instance from current URL querystring.
2var queryParams = new URLSearchParams(window.location.search); 
3// Set new or modify existing parameter value.
4queryParams.set("myParam", "myValue"); 
5// Replace current querystring with the new one.
6history.replaceState(null, null, `?${queryParams.toString()}`);
7// Or create new history entry with push state
8history.pushState(null,null, `?${queryParams.toString()}`);