Set intervals for setTimeout() function - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setInterval

Description

Set intervals for setTimeout() function

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   w w w  .jav  a2  s .co m*/

(function(){
  var intervals = [1,1,1,4,3,7];
  (function update(next){
    document.body.innerHTML = new Date();
    setTimeout(function(){
      update((next + 1)%intervals.length);
    }, intervals[next]*1000);
  })(0);
})();


    }

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

Related Tutorials