- Forums
- HTML
- How To Automatically Reload Web Page
have you seen those websites where you are visiting and then the page automatically refreshes every so many minutes or so? so you are here probably because you want to know how do they do that [2715], Last Updated: Mon Jun 24, 2024
Webune Support
Sat Feb 27, 2010
0 Comments
523 Visits
have you seen those websites where you are visiting and then the page automatically refreshes every so many minutes or so? so you are here probably because you want to know how do they do that?
well, if so, you are in luck, we have create a simple PHP script to show you how you can see how it works.
NOTE: if you dont have PHP on your website yet, signup today with us, Webune provides excellent PHP hosting.
the first thing you want to do to see this script in action is to open your favorite text editor. i am using windows to write this tutorial, so i will be using notepad. open a blank notepad and copy and paste the following PHP code:
PHP CODE: (
webune-reload.php)
<html>
<title>Refresh Web Page by Webune.com</title>
<head>
<script type="text/JavaScript">
<!--
function RefreshTime(Seconds) {
setTimeout("location.reload(true);",(Seconds *1000 ));
}
// -->
</script>
</head>
<body onload="JavaScript:RefreshTime(10);">
<?php echo 'This page refreshes every 10 seconds Last Refresh Time was: <strong style="color:red">'.date("D M d, Y G:i:s a").'</strong><BR><BR>'; ?>
<p align="center">Courtesy of<br><a href="http://www.webune.com"><img src="http://www.webune.com/images/headers/default_logo.jpg" alt="Webune Hosting" border="0"><br />Webune Web Hosting</a></p>
</body>
</html>
now save the file as
webune-reload.php, after you have save
webune-reload.php upload to your web server and test it, you will see the page will automatically refresh every 10 minutes.
pay special attention to the following code, which its important:
<body onload="JavaScript:RefreshTime(10);">
the as you can see from the code, we added javascript to the body tag to start the RefreshTime() javascript function.
if you are prefer, we have created the file for you. just download from the attachments area below:
reload.zip