Click here to Skip to main content
16,020,622 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi all,

I have to refresh a page at each hours e.g(1,2,3.....24).

Please help

Mohd Wasif
Posted
Updated 19-Mar-23 16:11pm

<pre lang="Javascript">

setInterval(function(){
  // reload the page
  location.reload();
}, 3600000); // 3600000 milliseconds = 1 hour
 
Share this answer
 
Hi,

You can use meta tag to achieve this:
XML
<meta http-equiv="refresh" content="3600">

Here content is number of seconds after which page will be refreshed.

http://www.mindfiresolutions.com/Autorefresh-an-ASPNET-aspx-web-page-37.php[^]

Auto Refresh Web Page[^]

http://www.grizzlyweb.com/webmaster/javascripts/refresh.asp[^]
 
Share this answer
 
v2
Comments
Mohd Wasif 10-May-12 2:18am    
I want that if time is 1:00 am .....12:00 pm then each hours I want page to be refreshed.
Deepak_Sharma_ 10-May-12 2:37am    
Go to last url above and in the refresh() function try to put your logic to refresh page in your preferred time
lllomh 22-Nov-19 1:03am    
great
Try this:
ASP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
// <![CDATA[
    function bed(){
        var now = new Date();
        var hr = now.getHours();
        var targ = document.getElementById('time_alert');

        targ.firstChild.nodeValue = (hr <= 23) ? hr+"00 Hours. You're good!!" : hr+"00 Hours. You need to go to bed";

        setTimeout('bed()', 3600000);
    }

    onload = bed;
// ]]>
</script>
</head>

<body>
<span id="time_alert">&nbsp;</span>
</body>
</html>


Or else have a look on following link for reference:
Refresh a page[^]
Auto Postback or Refresh page for every defined time interval[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900