Auto-Refresh using Javascript

Posted by Prabhukiran345 under JavaScript category on | Points: 40 | Views : 509
We can 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.

<script type="text/JavaScript">
function timedRefresh(timeoutPeriod) {
// -->
<body onload="JavaScript:timedRefresh(5000);">
<p>This page will refresh every 5 seconds. This is because we're using the 'onload' event to call our function. We are passing in the value '5000', which equals 5 seconds.</p>
<p>But hey, try not to annoy your users too much with unnecessary page refreshes every few seconds!</p>

Comments or Responses

Login to post response