|
Q1250 How do I set a delay between two statements?
irt.org | Knowledge Base | JavaScript | Timeout | Q1250 [ previous next ]
Q1250 How do I set a delay between two statements?
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...
}
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.