1

What is the best way to pause in JavaScript. I have attempted to use the setTimeout() function before, but I really got confused on how it works.

user1187968
  • 7,154
  • 16
  • 81
  • 152

1 Answers1

0
var pauseTime = 1000; //this is in milliseconds
setTimeout(runThisFunction,pauseTime);

function runThisFunction(){
 alert("i waited a second to run!");
}

it works by waiting x milliseconds then calls the function you pass .. in this case the function name is runThisFunction

samccone
  • 10,746
  • 7
  • 43
  • 50
  • If you replace the alert with a print statement, it will NOT guarantee that the function will run for x milliseconds. – user1187968 Mar 29 '12 at 16:36