If you need an item to be repeat at a set interval, you use var obj = setInterval(callback,duration) type of arrangement.
In your example this would likely look like
var s1obj = setInterval(s1,4000);
var s2obj = setInterval(s2,8000);
var s3obj = setInterval(s3,12000);
the use of obj is in case you wish to cease an interval timer by calling clearInterval( obj ); which will clear that timer.
You do not nest or "loop" them with a for loop. SetTimeout is not the way to set a timer to repeat because of the time lag that introduced and drag on site performance as your setting many timeouts and an interval only needs setting once.
Last edited by JunkMale; 10-19-2011 at 04:35 PM.
Reason: Stuff to add...
and all those functions will be called at those number of milliseconds. You would onlu need to wrap them in a function and have the document.body.onload = startItUp(); function to call that function to trigger the functions at regular intervals.
Last edited by JunkMale; 10-19-2011 at 04:52 PM.
Reason: Missin stuff...
will cause those timers to be set 8 seconds after the page script loads, the page could still be loading which is why I suggested the document.body.onload method to ensure that the function is called when the document loads.
When set, the functions s1 to 3 will be called at those specified intervals.
jQuery what? why not learn to do it the easy way through plain old scripting...
which might make a difference. I would advice that you load from a fresh the page as you may have interval timers running... once set the interval timers will run until the page is closed or navigated away from.
I just tried a script with the change to the function call within quotes with () and it worked fine on my browser.