...

View Full Version : overlapping setTimeout



Ultragames
01-18-2006, 02:38 AM
I have a function that calls itself every 2 min via setTimeout to reload a frame. However, action by the user may change that frame 1 min into the timer, therefore running that function again, and therefore setting the timer again.

So does that mean that i'm going to get overlapping setTimeouts? If so, there any way i can cancel any timers put on a certain function before running it again?

liorean
01-18-2006, 02:46 AM
If you store the timeout in a variable, you can clear it like this:
var
timeout=setTimeout(oogle,boogle);

/- - -/

if(shouldClearTimeOut)
clearTimeout(timeout);

Ultragames
01-18-2006, 02:50 AM
THough its not fatal, Firefox complains when doing a clearTimeout on a setTimeout that hasn't started yet. Anything i can do to stop it from complaining?

THanks BTW.

glenngv
01-18-2006, 04:04 AM
if (timeout) clearTimeout(timeout);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum