Click to See Complete Forum and Search --> : need help


vicious
05-20-2003, 04:03 AM
okay,
I want a script that keeps on checking the time and when it hits exactly 2 pm, and 4am, it opens a site.

Anyone know how?

Gollum
05-20-2003, 04:19 AM
What you could do is work out which of 2pm and 4am comes next, work out how long it is till then, and then set a timeout to wait for it. e.g.

function Go()
{
window.location = "http://somwhere.else.com";
}

function OnLoad()
{
var d = new Date();
var h = d.getHours();
var t = new Date();
if ( h < 4 ) t.setHours(4);
else if ( h < 14 ) t.setHours(14);
else
{
t.setHours(4);
t.setTime(t.getTime() + 86400000); // tomorrow
}

var ms = t.getTime() - d.getTime();

window.setTimeout("Go();", ms);
}

vicious
05-21-2003, 05:40 AM
thanks

but i was looking for something that I could add add times down to the half-hour

Also, i was wondering how i could have a text that reads:
Next opening: hh:mm:ss

thanks anyway