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

Contact

604-309-8713
info@solidfoundationwebdev.com

Send Me A Message

I would love to get in touch and talk about your next project. Feel free to send a message and I will get back to you shortly.

Get Connected