[SOLVED AGAIN] Newbie - Counter script
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

[SOLVED AGAIN] Newbie - Counter script

From: Bundy <bigbadbundyREMOVETHIS@vfemail.net>
Date: Wed Jan 11 2006 - 02:33:10 CET

Lee wrote:
> Bundy said:
>
>
>>function every_second()
>>{
>> for (x=1; x<5; x++)
>> {
>> setTimeout("second_function()",2000);
>> }
>>}
>
>
> When posting code, please convert TAB characters to spaces.
>
> The setTimeout() function does not insert any delay.
> It simply schedules the expression to be evaluated after the
> specified delay. Once it has been scheduled (which takes
> almost no time at all), processing continues. In your case,
> it then immediately schedules the next invocation of your
> second_function().
>
> The method that Evertjan has posted is generally preferred,
> but as an illustration, here's another way to do what you
> seem to want. Each invocation is scheduled to occur two
> seconds later than the previous one:
>
> function every_second()
> {
> for (x=1; x<5; x++)
> {
> setTimeout("second_function()",2000*x);
> }
> }
>

Thanks

This had me perplexed, now I understand.

Bundy
Received on Tue Jan 17 17:08:21 2006