I have a pretty normal setInterval call (I think):
var myInterval = setInterval("myFunction('passVar1', 'passedVar2')", 8000);
It runs perfectly if I’m on the page, but if I leave the page open for awhile (or minimize it?), when I come back, it’s like it just built up all the myFunction calls into a queue and tries to run through them all really fast to “catch up”. Then, when it catches back up, it runs at 8 seconds apart again like it’s supposed to.
Am I doing something wrong? I’m using Firefox 5 at the moment – if that has anything to do with it. Thoughts? TIA.
For one thing fix your
setIntervalso it doesnt use eval:Second, it depends on the browser what the interval does or does not do.
UPDATE:
Based on comments below and the related chat discussion here is a fiddle using
setTimeout:http://jsfiddle.net/maniator/VR7WE/
UPDATE:
Based on further discussion, turns out it was an issue with jquery’s animate
The following fiddle only runs the timeout when the animate is done: http://jsfiddle.net/maniator/c869Z/5/