Evertjan. wrote:
> Bundy wrote on 10 jan 2006 in comp.lang.javascript:
>
>
>><script language="JavaScript" type="text/JavaScript">
>
>
> language="JavaScript" do not use anymore!
>
>
>>var abc = 0;
>>
>>function every_second()
>>{
>> for (x=1; x<5; x++)
>> {
>> setTimeout("second_function()",2000);
>> }
>>}
>
>
> All 4 timeouts staart at nearly the same time and fire at nearly the same
> time
>
>
>>function second_function()
>>{
>> para1.innerText = abc;
>
>
> .innerText is IE only!
>
>
>> abc++;
>> }
>>
>></SCRIPT>
>></head>
>><body onLoad="every_second();">
>><p id="para1" > Start </p>
>></body>
>></html>
>>
>
>
> Try:
>
> <script type="text/JavaScript">
> var abc = 0;
> function myFunction(){
> para1.innerHTML = abc++;
> setTimeout('myFunction()',2000);
> }
> </script>
>
> <body onLoad='myFunction();'>
> <p id='para1'>x</p>
>
>
>
>
Thanks.
To stop script counting to 4 added inside funtion
if(abc<5)
{
setTimeout('myFunction()',2000);
}
else
{
para1.innerHTML = "finishing counting to four";
return;
}
Bundy
Received on Tue Jan 17 17:07:36 2006