|
Articles > JavaScript > What is the difference between window.location.href=window.location.href and window.location.reload |
|
What is the difference between window.location.href=window.location.href and window.location.reload
Author: Venkata Sudhakar
The below example shows how to refresh a page using window.location.reload and window.location.href.
window.location.reload works very similar to browser refresh button action and reloads the current page by resending POST data. For POST requests this API prompts the user before sending the request to Server.
window.location.href=window.location.href works similar to browser refresh button action and reloads the current page without passing POST data. So this is good option for GET requests. However this approach may not work if you have anchor (#) in the URL. In such cases it's better to use window.location.reload.
|
|