How To Append Parameters To Current Url And Reload With Javascript

Posted by Weston Ganger

One common task for javascript is to append parameters to a URL and reload the page. Heres a quick one liner to do so.


/* Add single parameter */
window.location.search += "&my_param=foobar"

/* Add multiple parameters */
window.location.search += "&my_field=foo&other_field=bar"

This will add the parameter and refreshYou will still see the original parameters but new ones will take precedence because it is last in the parameters list.


Related External Links:

Article Topic:Software Development - Javascript

Date:September 20, 2016

Recommended Posts