title: Javascript, Make a loop between 2 Pages and set a timer on 1
body: <p>I want to create a while loop between 2 html page (Or a prompt where I can ask a question) and make so that if I give the wrong answer I get redirected to another HTML page that will remain for 5 seconds before getting back to the prompt.</p>
  <p>I am trying the following code</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
      &lt;script&gt;
          var pass;
              pass = prompt(&quot;The corret answer is 1&quot;);
          if (pass == &quot;1&quot;) {
              document.location.href = &quot;https://stackoverflow.com/questions/40539097/redirect-user-to-another-html-page-if-the-condition-is-true&quot;;
          } else {
              setTimeout(function(){
                window.location.href = 'prova2.html';
           }, 5000);
          }
  &lt;/script&gt;
      &lt;body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>The Problem is that the page &quot;prova2.html&quot; came out after 5 second.
  Instead I want that it remain visible for 5 seconds.</p>