Click here to Skip to main content
11,708,980 members (73,088 online)
Click here to Skip to main content

Automatically refresh page after some interval

, 20 Jun 2011 CPOL 7.9K 1
Rate this:
Please Sign up or sign in to vote.


Refresh page using JavaScript.


<title>Refresh page using Javascript</title>
<script type="text/JavaScript">
	function RefreshPage(Period) 
		setTimeout("location.reload(true);", Period);
/* Optional code */
	var Today = new Date();
	var day = Today.getDate();
	var month = Today.getMonth();
	var year = Today.getFullYear();
	var hours = Today.getHours();
	var minutes = Today.getMinutes();
	var seconds = Today.getSeconds();
	document.write(day + "/" + month + "/" + year + " " + hours + ":" + minutes + ":" + seconds)
/* End of Optional code */
<body  önload="javaScript:RefreshPage(1000);">

Browser Compatibility

I have tested this script in the following Web browsers:

  • Internet Explorer
  • Mozilla Firefox
  • Google Chrome
  • Safari
  • Opera


20/5/2011 17:56:51

You can see the running date-time of today on page refresh. Here I gave 1000 milliseconds (1 sec) in the code (for page refresh) and you can change the value based on your requirement.


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


About the Author

Web Developer
India India
Programmer | Dude | ||||||

About him & his blog? check out here. Currently he's updating the site, he'll return soon there with more things*.

In Codeproject, he posted a blogpost & more than couple of Tip/Tricks, hope he'll write more soon.

Favorite techs are MVC, WCF, Mobile, HTML5, CSS3, jQuery, etc.,

His hobbies are watching movies, CP, being alone, etc., But now he's working on something*.

* - SCAMP???

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150819.1 | Last Updated 20 Jun 2011
Article Copyright 2011 by thatraja
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid