558 B
558 B
Change parameters of URL without refreshing it
const changeURLParams = (newValue) => {
const newURL = `${window.location.pathname}${newValue}`;
window.history.pushState({ path: newURL }, "", newURL);
};
Change queries of URL without refreshing it
const changeQueryParams = () => {
const urlParams = new URLSearchParams(window.location.search);
urlParams.set('queryParamName', 'newValue');
const newURL = `${window.location.pathname}?${urlParams.toString()}`;
window.history.pushState({ path: newURL }, '', newURL);
};