Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 581
KillerFish Avatar asked Mar 08 '11 13:03

KillerFish


People also ask

How do I refresh current URL?

You can use the location. reload() JavaScript method to reload the current URL. This method functions similarly to the browser's Refresh button. The reload() method is the main method responsible for page reloading.

What does Window location reload do?

Window location. The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.

How do I stop jquery from refreshing?

You can use event. preventDefault() to prevent the default event (click) from occurring.

How can I tell if jquery is refreshing a page?

On Refresh/Reload/F5: If user will refresh the page, first window. onbeforeunload will fire with IsRefresh value = "Close" and then window. onload will fire with IsRefresh value = "Load", so now you can determine at last that your page is refreshing.


1 Answers

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

if(window.location.hostname == "www.myweb.com")    window.location.href += "?single"; 
like image 163
Mark Coleman Avatar answered Sep 19 '22 20:09

Mark Coleman