Javascript

How To Append Parameters To Current Url And Reload With Javascript

Posted by Weston Ganger on September 20, 2016

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:


Posted in Javascript and Tagged with javascript parameters 


Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts