Page Number: Page 1 of 1
Actual Results
- Mike Duskis
- Forum: Programming / Scripting / Coding Forum
- Topic: JavaScript Sleep Function
- Subject: JavaScript Sleep Function
- Replies: 22
- Views: 109771
- Subject: JavaScript Sleep Function
Posted: October 10th, 2008, 12:25 pm
joebert, I admit that sleeping in JavaScript is a kludgy thing to do, especially if we're talking about a Web application. Any time I consider sleeping, I usually come up with a more elegant solution. I came across this discussion because I finally found a case where I really did want to sleep. I wa...
- Mike Duskis
- Forum: Programming / Scripting / Coding Forum
- Topic: JavaScript Sleep Function
- Subject: JavaScript Sleep Function
- Replies: 22
- Views: 109771
- Subject: JavaScript Sleep Function
Posted: September 30th, 2008, 4:10 pm
Excellent concept, Carnix. I think we can implement it with less code:
/**
* Delay for a number of milliseconds
*/
function sleep(delay)
{
var start = new Date().getTime();
while (new Date().getTime() < start + delay);
}
* Delay for a number of milliseconds
*/
function sleep(delay)
{
var start = new Date().getTime();
while (new Date().getTime() < start + delay);
}
- /**
- * Delay for a number of milliseconds
- */
- function sleep(delay)
- {
- var start = new Date().getTime();
- while (new Date().getTime() < start + delay);
- }

