JavaScript Sleep()


How do I pause execution in JavaScript?

How do I pause execution in JavaScript?

Is there a wait statement in JavaScript?

Is there a sleep method to pause execution?

Is there a sleep method to pause execution?




I found a useful article how do I pause execution in JavaScript to description how to delay JavaScript process.



some example

function pause(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}




function pause(numberMillis) {
var dialogScript =
'window.setTimeout(' +
' function () { window.close(); },
' + numberMillis + ');';
var result =


// For IE5.
window.showModalDialog(
'javascript:document.writeln(' +
'"< script>' + dialogScript + '<' + '/script>")');


/* For NN6, but it requires a trusted script.
openDialog(
'javascript:document.writeln(' +
'"< script>' + dialogScript + '<' + '/script>"',
'pauseDialog', 'modal=1,width=10,height=10');
*/
}



explain? why not visit How do I pause execution in JavaScript

Comments

Karl said…
Terrific, thanks very much for your help!
websecure said…
it blocks the client

Popular Posts