How to Refresh/Reload a Page with jQuery/JS
- Get current page address (URL)
- Redirect the browser to another page
- Reload/refresh the same page
The History interface allows manipulation of the browser session history , that is the pages visited in the tab or frame that the current page is loaded in. The history.go() method loads a URL from the browsers history depending on the parameter passed to it. If the parameter passed is '0', it reloads the current page .
If the current page was loaded by a POST request , you may want to use
- location.href = location.href
- window.location = window.location
- window.self.window.self.window.window.location = window.location
Refresh a page after certain delay jQuery
The refresh code can be executed after a certain period of time using the setTimeout() method . This method has a delay parameter which denotes the time after which the function will execute. This value is given in milliseconds . The amount of time in seconds to be delayed in multiplied by 1000 to convert it to milliseconds.