You are here: irt.org | FAQ | JavaScript | Timeout | Q1250 [ previous next ]
There is no pause or sleep in JavaScript.
Split your function and call the second one with a setTimeout
// before: function callTwoStatements() { statement1... for (i=0;i<10000;i++) ; // do nothing but eat CPU statement2... } // after: function callStatement1() { statement1... setTimeout('callStatement2()',2000); // delay 2 seconds } function callStatement2() { statement2... }