Thursday 29 March 2012

JavaScript: Reload Page

Question:

How do you reload a web page with JavaScript?

Answer:

You ask the DOM API of your browser. There are several ways to do this.
The most common ones use the window.location object of the DOM.
// set window location 
window.location.href=window.location.href;

// reload window location
window.location.reload(true);

// move in navigation history of you browser to Now
history.go(0);


Here is a button that triggers a page reload.




No comments: