Add a 10 second pause timeout - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setTimeout

Description

Add a 10 second pause timeout

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() {/*w  w w.  j a  v  a2 s .  c  o  m*/
function timeoutLoop(i, max, callback) {
    if (i < max) {
        callback(i);
        i++;
        setTimeout(function(){
             timeoutLoop(i, max, callback);}, 2000);
    }
}
timeoutLoop(0, 20, function(i) {
    document.write("Iteration " + i + "<br>");
});
    });

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

Related Tutorials