tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Articles > JavaScript > How to refresh a page using window.location.reload and window.location.href

How to refresh a page using window.location.reload and window.location.href

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.


 
  


  
bl  br