Javascript examples for Browser Object Model:Window setTimeout
get setTimeout to start counting as soon as the alert box is open
<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>