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
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.
Window location. The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.
You can use event. preventDefault() to prevent the default event (click) from occurring.
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.
You should be able to accomplish this by using location.href
if(window.location.hostname == "www.myweb.com") window.location.href += "?single";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With