M
masonsimon
I'm trying to use the following function to update an Opera widget that
I'm writing, but it doesn't seem to work.
function runAt(time_to_run_at, what_to_run)
{
//time_to_run_at is a Date
//what_to_run is either a function reference or a string of JavaScript
var now = new Date();
time_until_run = time_to_run_at.getTime() - now.getTime();
window.setTimeout(what_to_run, time_until_run);
}
The timeouts that I'm setting with this are many hours long. I've
tested the function with shorter time lengths and it seems to work
fine. I've noticed this behavior in Firefox 1.5 and Opera 9 beta 2.
Does anyone else have experience with this? Is there some maximum
timeout length that I shouldn't exceed?
I'm thinking that I could rewrite the function to set a bunch of
subsequent timeouts that would sum up to the total timeout that I want,
but I'm lazy, so if anyone already knows a good maximum timeout to set,
I'd appreciate it if you shared that bit of knowledge.
Any help is appreciated. Thanks!
-Mason
I'm writing, but it doesn't seem to work.
function runAt(time_to_run_at, what_to_run)
{
//time_to_run_at is a Date
//what_to_run is either a function reference or a string of JavaScript
var now = new Date();
time_until_run = time_to_run_at.getTime() - now.getTime();
window.setTimeout(what_to_run, time_until_run);
}
The timeouts that I'm setting with this are many hours long. I've
tested the function with shorter time lengths and it seems to work
fine. I've noticed this behavior in Firefox 1.5 and Opera 9 beta 2.
too long.From this I conclude that setTimeout just dies when its timeouts are
Does anyone else have experience with this? Is there some maximum
timeout length that I shouldn't exceed?
I'm thinking that I could rewrite the function to set a bunch of
subsequent timeouts that would sum up to the total timeout that I want,
but I'm lazy, so if anyone already knows a good maximum timeout to set,
I'd appreciate it if you shared that bit of knowledge.
Any help is appreciated. Thanks!
-Mason