How can I create a while loop that spans across 2 HTML pages or use a prompt to ask a question? If the wrong answer is provided, I would like to be redirected to another HTML page which will display for 5 seconds before returning to the prompt.
This is my current attempt at coding:
<!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 issue I'm facing is that the "prova2.html" page only appears after 5 seconds. How can I make it visible for the entire duration?