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!

make browser refresh at a specific time 2

Status
Not open for further replies.

dugen

Programmer
Jun 16, 2003
59
US
Hi,

I am looking for a way to refresh a browser at a specific time. For example: i want the page to refresh at 11:00am, 5:00pm and 8:00pm.

I dont want to use time intervals because the browser window may be opened at a different time each day, which will throw off the time at which the browser is supposed to refresh.

Any Ideas?


Thanks
 
kaht answered something similar to this a few weeks ago, I'll see if I can dig it up and I may add onto it.



[monkey][snake] <.
 
Here it is: thread216-1353248

The only thing I say against this example is you need to grab the server time, not the client time.

If you have any questions about that feel free to ask.

[monkey][snake] <.
 
Awesome! Thats what I was looking For.

Thanks
 
Surprisingly (?) I had some code to handle the same thing. I've appended it to kaht's code... it'll let you specify an array of times to check for relead (but otherwise is the same thing).

Code:
window.setInterval("checkForRefresh()", 60000);

/* the times to trigger the reload hh:mm */
var targetTimes = ['02:46', '07:47', '16:20', '22:15'];

/* this will reload the page if any one of the target times matches the current time */
function checkForRefresh() {
	var now = new Date();
	for (var i=0, max=targetTimes.length; i < max; i++) {
		var targetTime = targetTimes[i].split(':');
		if (targetTime[0] == now.getHours() && targetTime[1] == now.getMinutes()) {
			window.refresh();
		}
	}
}

Cheers.
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
I like your code Jeffy, since I'm a code stealer, have a star.

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top