JavaScript sleep() without freeze in Firefox

  1. //found@http://www.daniweb.com/forums/post742619.html#post742619
  2.  
  3. /**
  4.  * Netscape compatible WaitForDelay function.
  5.  * You can use it as an alternative to Thread.Sleep() in any major programming language
  6.  * that support it while <strong class="highlight">JavaScript</strong> it self doesn't have any built-in function to do such a thing.
  7.  * parameters:
  8.  * (Number) delay in millisecond
  9.  */
  10. function nsWaitForDelay(delay) {
  11. /**
  12. * Just uncomment this code if you're building an extention for Firefox.
  13. * Since FF3, we'll have to ask for user permission to execute XPCOM objects.
  14. */