[Javascript] Sleep / Delay function

Rodney Myers rodney at aflyingstart.net
Wed Jun 20 16:09:39 CDT 2001


function delay(gap){ /* gap is in millisecs */
var then,now; then=new Date().getTime();
now=then;
while((now-then)<gap)
{now=new Date().getTime();}
}//

I will leave to you to make the gap parameter seconds instead of millisecs !

hth

Rodney


Reuben D Budiardja wrote:

> Hi,
> Can anyone  tell me is there something like sleep or delay function in
> javascript with argument in second ? That is, I want the javascript to wait a
> few second before execute the next line of code. How can I do that?
>
> Second, what is the best place to get references for javascript function,
> syntax, object addressing, etc? I always have difficulties of finding
> reference on the net.
>
> Thanks.
> Reuben D. Budiardja
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript

--
Shop at ssistant Add-ons and Developer Workshops
http://www.aflyingstart.net/addons/

Enquiries regarding Shop at ssistant Classic training :
Call 01256 880770

Rodney Myers
Based in Oxford, England
Technical Director, Shop at ssistant eCommerce Solutions






More information about the Javascript mailing list