Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Javascript - Sleep (See related posts)

// Effettuare uno sleep dello script di uno script

function pause(millisecondi)
{
    var now = new Date();
    var exitTime = now.getTime() + millisecondi;

    while(true)
    {
        now = new Date();
        if(now.getTime() > exitTime) return;
    }
}

Comments on this post

Mokhet posts on Jul 08, 2006 at 00:01
This code must not be used, it is a bad practice. It is completly freezing the client and as a result, you can't correctly manage events in same time. The only way is to use a timeout.
jonasraoni posts on Aug 10, 2006 at 16:33
Horrible approach =/

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts