How to reload a page using JavaScript

JavaScript 1.2 and newer

// 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:

JavaScript 1.1

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

JavaScript 1.0

window.location.href = window.location.pathname + + window.location.hash;
// creates a history entry

Leave a Comment