Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic page refresh at specific time of day? 1

Status
Not open for further replies.

Shrap

Technical User
Apr 4, 2007
4
GB
Hi guys,

Basically, cutting a long story short. I'm in need of a script which refreshes a web page at a certain time of day (in my case, 1pm) instead of a generic refresh after a pre-defined number of minutes.

Is this possibly to do? If so, how? Any advice would be great.

Thanks all.
 
Not sure why you'd want to do this, but this should work:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>title test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">

//60000 milliseconds is 1 minute
window.setInterval("checkForRefresh()", 60000);

function checkForRefresh() {
   var now = new Date();
   if (now.getHours() == 13 && now.getMinutes() == 0) {
      window.refresh();
   }
}



</script>
<style type="text/css"></style>
</head>
<body>
</body>
</html>

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
uncle_rico_thumb.jpg
 
What time zone do you want to use for the standard? Your best bet to make sure everyone viewing the page does it at the same time is to write the server time in the Javascript with server-side scripting, then calculate the offset from the time on the client-side computer and work from there. Otherwise you're at the mercy of the time on the client computer, which will vary depending on time zone and other things.

Lee
 
Hi guys,

All I want to do is make the page auto refresh at 1pm. It's only going to be used internally, on a select few of computers.

Code:
<script type="text/javascript">

//60000 milliseconds is 1 minute
window.setInterval("checkForRefresh()", 60000);

function checkForRefresh() {
   var now = new Date();
   if (now.getHours() == 13 && now.getMinutes() == 0) {
      window.refresh();
   }
}



</script>

So that should be all I need?

Thanks.
 
I forgot to mention that the time zone would be GMT, as I live in the UK.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top