This refresh page javascript code automatically reloads the webpage at a given time period. By default, the refresh action is displayed in the status bar. This can be set to no. Simply follow the instructions within the javascript comments.
This script below has been set to refresh a web page after 30 seconds but you can configure the refresh time to suit your needs. Very useful to give live scores for football, basketball and other games, etc.
Adding the javascript to your webpage:
Copy the javascript code below and paste this between the <head> and </head> tags of your web site page. Change the refresh interval where indicated.
Code:
<script
language="JavaScript"> // CREDITS: // Automatic Page Refresher by
Peter Gehrig and Urs Dudli www.24fun.com // Permission given to use the script
provided that this notice remains as is. // Additional scripts can be found at
http://www.hypergurl.com // Configure refresh interval (in seconds) var refreshinterval=5
// Shall the coundown be displayed inside your status bar? Say "yes"
or "no" below: var displaycountdown="yes" // Do not edit the
code below var starttime var nowtime var reloadseconds=0 var secondssinceloaded=0
function starttime() { starttime=new Date() starttime=starttime.getTime() countdown()
} function countdown() { nowtime= new Date() nowtime=nowtime.getTime() secondssinceloaded=(nowtime-starttime)/1000
reloadseconds=Math.round(refreshinterval-secondssinceloaded) if (refreshinterval>=secondssinceloaded)
{ var timer=setTimeout("countdown()",1000) if (displaycountdown=="yes")
{ window.status="Page refreshing in "+reloadseconds+ " seconds"
} } else { clearTimeout(timer) window.location.reload(true) } } window.onload=starttime
</script>
Bookmarks