Click to See Complete Forum and Search --> : How to execute next statement after a specified period?


Amo_Lin
01-08-2003, 12:00 AM
How to execute next statement after a specified period? I don't think setTimeOut() can do this.

for example


for (i=1; i<10;i++)
{
document.write("******************");

/*Here, How to stop for 10 seconds to begin next cycle. */
}

Thank you!

gil davis
01-08-2003, 05:27 AM
You cannot "stop". You can use setTimeout() to delay execution of the next part, but it must be in a separate function:

function nextPart() {
// do what you want delayed
}
...
for (i=1; i<10;i++) {
document.write("******************");
setTimeout("nextPart()", 10 * i * 1000);}

This probably is not exactly what you want, but if you give a more complete example, someone can help adapt it accordingly.