Possible Duplicate:
Sleep in Javascript
What do I do if I want a JavaScript version of sleep()?
Is it possible to implement a sleep function in Javascript?
I have this code:
var state = true;
$('#changeState').click(function(){
if (state == true)
state = false
else
state = true
})
while() {
//do something
if (state == false){
sleep();
}
}
Is it feasable?
Thanks for your help.
If you attempt to make the browser “busy wait” it will become unresponsive, and may generate warnings to that effect.
You must allow the normal event processing loop to continue, or your
clickhandler will never be called.