Automatically refresh page after some interval...

Description

Refresh page using JavaScript.

Code

<html>
<head>
<title>Refresh page using Javascript</title>
<script type="text/JavaScript">
 function RefreshPage(Period) 
 {
  setTimeout("location.reload(true);", Period);
 }
/* Optional code */
 var Today = new Date();
 var day = Today.getDate();
 var month = Today.getMonth();
 var year = Today.getFullYear();
 var hours = Today.getHours();
 var minutes = Today.getMinutes();
 var seconds = Today.getSeconds();
 document.write(day + "/" + month + "/" + year + " " + hours + ":" + minutes + ":" + seconds)
/* End of Optional code */
</script>
</head>
<body  önload="javaScript:RefreshPage(1000);">
</body>
</html>

Browser Compatibility

I have tested this script in the following Web browsers:
  • Internet Explorer
  • Mozilla Firefox
  • Google Chrome
  • Safari
  • Opera

Output

20/5/2011 17:56:51
You can see the running date-time of today on page refresh. Here I gave 1000 milliseconds (1 sec) in the code (for page refresh) and you can change the value based on your requirement.

0 Response to "Automatically refresh page after some interval..."