Multiple setTimeouts ?

admin

Administrator
Staff member
Can I have multiple setTimeouts active at one time? I cannot find the answer to this in any of my Javascript books.
But when I try it, I get strange results that lead me to believe my clearTimeouts are not working.

e.g. I set up a loop using setTimeout with an interval of 5000 millisecs, within this loop I set up 2 consecutive setTimeouts of 20 each, clearing each after they finish. Both of the inner timeouts are recursive and execute 50 times before terminating (i.e. a total of 1000 millisecs each).

What is happening is that after the first of the 'inner' timeouts finishes and I have cleared it, my second 'inner' timeout begins but is then immediately cut short by the first inner timeout firing again. I use different timeout names for all 3 timeouts.

Is there any way to eliminate the timouts and use a programmed delay (a wait) instead?

Does setInterval work with the latest browsers, I have not been able to get it to work with IE 6?
 
Top