Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload a page using JavaScript

Tags:

javascript

How can I reload the page using JavaScript?

I need a method that works in all browsers.

like image 687
Resh Avatar asked Sep 15 '10 06:09

Resh


1 Answers

JavaScript 1.2 and newer

window.location.reload(); // If we needed to force the document to be fetched from the // web server again (such as where the document contents // change dynamically but cache control headers are not // configured properly), Firefox supports a non-standard // parameter that can be set to true to bypass the cache: //window.location.reload(true); 

JavaScript 1.1

window.location.replace(window.location.pathname + window.location.search + window.location.hash); // does not create a history entry 

JavaScript 1.0

window.location.href = window.location.pathname + window.location.search + window.location.hash; // creates a history entry 
like image 137
gianebao Avatar answered Oct 09 '22 17:10

gianebao