View Full Version : clearTimeout Loop Lags IE, but not FF

05-16-2009, 12:13 AM
Hey everyone, I have a question and hope for a answer.

On one of my pages, I have 5 timers running off setTimeouts

But I refresh the Timers every 2 seconds OR 10 seconds. (depending on the browser)

My problem lies in with, when I loop to clear them.

I did a alert and got a number around 844019


totalTimers is set at the timeouts,

totalTimers = setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);

and here is the loop to clear the timers,

while(tlc < totalTimers){

Is there a way to clear All Timers at once?

That way IE wont lag and ask to stop script because of how many loops it has to run through?:confused:

Firefox & Safari work fine.:thumbsup:

05-16-2009, 08:03 AM
My understanding of javascript tells me that there is only one variable called totalTimers so that there must be only one clearTimeout(totalTimers) command to stop it. What is that loop for? you clearTimeout() a number? Don't confound the variable, as an object, with its value.

And use an anonymous:

totalTimers = setTimeout(function(){displayTZCountDown(countdown-1,tzcd)},999);
//to stop it:

05-20-2009, 08:47 PM
Well the timers are reloaded (without clearing the old timers) into a DIV because for each product it has its own countdown timer until sale ends.

The timers get reloaded because it is a auction website that checks the DB for changes to the product, its timer, and its price.

So if I dont clear the timer, it will switch between the timer that loaded on page entrance and the timer that gets reloaded.

The website I am working on this for is a auction website

So what your saying is all I would need to put is
clearTimeout(totalTimers); and it should work?

And then there is that LAG/Glitch in IE that wont show new information (changes to the page) unless you refresh 10 times or reopen IE and go back to the page.