Answers for "update url parameters and create history entry"

0

update url parameters and create history entry

// Construct URLSearchParams object instance from current URL querystring.
var queryParams = new URLSearchParams(window.location.search); 
// Set new or modify existing parameter value.
queryParams.set("myParam", "myValue"); 
// Replace current querystring with the new one.
history.replaceState(null, null, `?${queryParams.toString()}`);
// Or create new history entry with push state
history.pushState(null,null, `?${queryParams.toString()}`);
Posted by: Guest on February-22-2021

Code answers related to "update url parameters and create history entry"

Code answers related to "Javascript"

Browse Popular Code Answers by Language