title: Need a delay within a for loop, Python, Flask, HTML, JavaScript
body: <p>Hello and apologies if this has been asked and answered, but after couple hours each day for the past week searching, I have yet to find a good solution.</p>
  <p>Issue:  I have a Python/Flask served site where I have a specific button that will allow me to open up every instance of my customers sites, loaded from a database (<strong>custdata</strong>).  The below code in it's original form works fine to open up all of the pages in new tabs.  The issue I am having is to help reduce the initial load upon requesting the pages, I would like to have a half second delay between each iteration within the for loop.</p>
  <p>Notes:  As seen below, I have tried to use the <em>setTimeout</em> option with a delay of 500 milliseconds, but this seems to only delay the opening of the first iteration of the subsequent pages.  The loop then opens the rest of the pages without any delay.</p>
  <p>For example:  If the database has 5 customers for a given server, the page will load, delay for 500ms, then load the 5 customer pages without any delay between them.  The desired effect is to delay the opening of the customer pages between each customer page.</p>
  <pre><code>  
  &lt;head&gt;
  &lt;script&gt;
  function myFunction() 
  {
      {% for mydata in custdata %}
          window.setTimeout(function(){
                  window.open(&quot;https://customer.mysite.com/launch/{{ custdata.customer_name }}&quot;, &quot;_blank&quot;);
          }, 500);
      {% endfor %}
  }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body onload=&quot;myFunction()&quot;&gt;
  Customer pages should have loaded.  If so, you can close this page.  If not, ensure popups are not blocked for this site.
  &lt;/body&gt;
  
  &lt;/html&gt;```
  </code></pre>