JavaScript Refresh Page
In JavaScript, you refresh the page using location.reload.
This code can be called automatically upon an event or simply when the user clicks on a link.
Example JavaScript Refresh code
Typing this code:
Results in this:
Auto-Refresh
You can also use JavaScript to refresh the page automatically after a given time period. Here, we are refreshing the page 5 seconds after the page loads. This results in the page continuously refreshing every 5 seconds.
This code...
View the result (opens in new window)
You can achieve the same effect using the HTML meta tag.
Other Refresh Tricks
By including your refresh code in a function, you can have complete control over when the page is refreshed.
Example 1
Instead of having the "page refresh" function called automatically when the page loads, you can call it only when the user performs some action - such as clicking on a link.
This code...
