I am looking to write a piece of javascript that will append a parameter to the current url and then refresh the page - how can I do this?
If you are developing for a modern browser, Instead of parsing the url parameters yourself- you can use the built in URL functions to do it for you like this:
const parser = new URL(url || window.location); parser.searchParams.set(key, value); window.location = parser.href;