Nothing is easy. Everything is hard. Please update your documentation.
window.location = "?page=account&this=that&foo=bar";
window.location.search = "?page=account&this=that&foo=bar";
Does not seem to work on Firefox or Edge. I make the change, I see no difference in the URL. I press the refresh (F5) and all is same as before
I opened the debug panel in FF and typed in 'window.location.search = "?foo=bar'. It refreshed the page and added the search parameters to the URL.
Try it this way.const params = new URLSearchParams(location.search);params.set('x_variable', "value");window.history.replaceState({}, '', `${location.pathname}?${params}`);
If you found this page useful, or you have any feedback, please leave a comment.
Does not seem to work on Firefox or Edge. I make the change, I see no difference in the URL. I press the refresh (F5) and all is same as before
ReplyDeleteI opened the debug panel in FF and typed in 'window.location.search = "?foo=bar'. It refreshed the page and added the search parameters to the URL.
DeleteTry it this way.
ReplyDeleteconst params = new URLSearchParams(location.search);
params.set('x_variable', "value");
window.history.replaceState({}, '', `${location.pathname}?${params}`);