How to refresh a page with jQuery by passing a parameter to URL

KillerFish picture KillerFish · Mar 8, 2011 · Viewed 123k times · Source

I am refreshing my page using jQuery:

location.reload();

This is working great but I want to refresh the same page by passing a parameter to URL.

How can I do this by using jQuery?

Ex:

If my url is www.myweb.com, I want to refresh this by passing a parameter like this

  www.myweb.com?single

Thank you

Answer

Mark Coleman picture Mark Coleman · Mar 8, 2011

You should be able to accomplish this by using location.href

if(window.location.hostname == "www.myweb.com"){
   window.location.href = window.location.href + "?single";
}