get setTimeout to start counting as soon as the alert box is open - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setTimeout

Description

get setTimeout to start counting as soon as the alert box is open

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 ww .  ja v  a2 s  .  c  om
var products = {
    price: '$69',
    dog: '$0',
    soul: '$minimum wage'
}, 
my = Object.keys(products);


var i=0, intval = setInterval(function() {
    console.log(my[i]);
    if(++i > my.length-1) { clearInterval(intval) }
}, 3000);
    }

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

Related Tutorials