Function: window.location.reload()

The location object offers the reload() function to programmatically reload the page. Call it and it will reload the page, much like pressing 'F5'.


Example:

The code:

<!-- click h1 then button -->
<h1 onclick="this.innerHTML=prompt('What should I say?','You\'re indecisive =P')">
Click to change text
</h1>

<button onclick="window.location.reload()">Reload page</button>

...as it appears on the Page:

Click to change text



Back to Knowledge Dump