Run URL one by one using loop - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image

Description

Run URL one by one using loop

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 a2s  .c o m
var my = ['http://google.com', 'http://www.yahoo.com', 'http://gmail.com'];
function work() {
    if(my.length==0) 
        return;
    var url = my.shift();
    var openWindow = window.open(url);
    setTimeout(function () {
        openWindow.close();
        work();
    }, 3000);
}
work();
    }

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

Related Tutorials