title: How to update a web page from javascript without exiting javascript
body: <p>I would like to animate an html page with something like this:</p>
  
  <pre><code>function showElements(a) {   
    for (i=1; i&lt;=a; i++)  {  
      var img = document.getElementById(getImageId(i));  
      img.style.visibility = 'visible';  
      pause(500);  
    }  
  }
  
  function pause(ms) {
    ms += new Date().getTime();
    while (new Date() &lt; ms){}
  }
  </code></pre>
  
  <p>Unfortunately, the page only renders once javascript completes.</p>
  
  <p>If I add      </p>
  
  <pre><code> window.location.reload();
  </code></pre>
  
  <p>after each pause(500); invocation, this seems to force my javascript to exit.  (At least, I do not reach the next line of code in my javascript.)</p>
  
  <p>If I insert</p>
  
  <pre><code> var answer=prompt("hello");
  </code></pre>
  
  <p>after each pause(500), this does exactly what I want (i.e. update of the page) except for the fact that I don't want an annoying prompt because I don't actually need any user input.</p>
  
  <p>So... is there <em>something</em> I can invoke after my pause that forces a refresh of the page, does not request any input from the user, and allows my script to continue?</p>