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.
I am trying the following code
<!DOCTYPE html>
<html>
<body>
    <script>
        var pass;
            pass = prompt("The corret answer is 1");
        if (pass == "1") {
            document.location.href = "https://stackoverflow.com/questions/40539097/redirect-user-to-another-html-page-if-the-condition-is-true";
        } else {
            setTimeout(function(){
              window.location.href = 'prova2.html';
         }, 5000);
        }
</script>
    <body>
</html>
The Problem is that the page "prova2.html" came out after 5 second. Instead I want that it remain visible for 5 seconds.
 
    