Sleep/Delay in Javascript


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function sleep(delay)
  2. {
  3. var start = new Date().getTime();
  4. while (new Date().getTime() < start + delay);
  5. }
  6.  
  7. //usage
  8. //wait for 3 seconds
  9. sleep(3000);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.