Tuesday, April 7, 2009

Auto-Refresh page at Specific Intervals

This will do a refresh once an hour:

<script language="JavaScript">
<!--
if (document.images)
    setTimeout('location.reload(true)',1000*3600); // forces a reload from the server
else
    setTimeout('location.href = location.href',1000*3600);  // just reloads the page
//-->
</script>
Alternative
Use
<meta http-equiv="refresh" content="3600;URL=name-of-this-page.html"> 
Some browsers might not understand the abbreviated form.
To refresh at 5 minutes past the hour according to the user's system clock:
<script type="text/javascript">
  var timer = setInterval("checkTime()", 1000 * 60 * 60);
   function checkTime()
  {
    if(new Date().getMinutes() == 5)
      self.location.reload(true);
  }
</script> 
This will not work if the user's browser doesn't support JavaScript; the meta-refresh will.
better of placing both since some browsers disable meta refresh:
<meta http-equiv="refresh" content="3600;URL=thesamepage.html"> 
<script type="text/javascript">
theHour="1"; //Input the hour
setTimeout("location.reload()",theHour*1000*60*60)
</script>

and for the 5 minutes:
<meta http-equiv="refresh" content="300;URL=thesamepage.html"> 
<script type="text/javascript">
theMinutes="5"; //Input the minutes
setTimeout("location.reload()",theMinutes*1000*60)
</script>

Mas Basy Network


Kebebasan berpendapat
itulah motto hidupku..
akan akan terus berusaha mencari keberkahan hidup meskipun diawali dengan tunggang langgang..
semelekethe weleh-weleh...
Subhanallah..