How to Achive Automatic page Refresh
Hello,
I have seen many sites where their pages automatically Refreshed, I always wonder that there should be lengthy code running behind it :whistling . I have created a page with some photos that should change periodically, and for that I want my webpage to simply refresh itself automatically.
Is there any easy way to make a simple page "refresh" automatically? Thanks
Re: How to Achive Automatic page Refresh
Theres also a meta tag that you can define on the head, but not sure wheter it refreshes even if the content has not finished loading or if it starts counting when the head section loaded. Code would be something like that:
<meta http-equiv="refresh" content="600">
Re: How to Achive Automatic page Refresh
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>
Re: How to Achive Automatic page Refresh
put the next line at the top of the page you wish to refresh :
<meta http-equiv=refresh content="X; URL=/..../index.html">
Replace X with an integer representing the number of seconds before the refresh.
The URL can be a path on the local computer or a link like http://go.to.that.site/index.html