SetTimeout() with variable delay and wait - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setTimeout

Description

SetTimeout() with variable delay and wait

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from www  .j a v  a 2  s .  c o m*/
var i = 0;
(function repeat(){
  if (i++ > 5) return;
  setTimeout(function(){
    document.write("Iteration" + i + "<br />");
    repeat();
  }, 5000);
})();
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials