I want to make a break in a for loop in javascript. My actually code is
<p id="1">The video opens</p>
<script>
for(i=0; i<5; i++) {
myWindow = window.open("VIDEO");
document.getElementById("1").innerHTML = "Wait";
setTimeout(myWindow.close(), 10000);
}
</script>
The video should start in a new tab, plays 10 seconds, and then closes. Then it starts again, plays anozher time 10 seconds and closes the video etc... But the Timeout isn't a real timeout. It makes only the myWindow.close() comes 10 seconds later That means, all 10 videos start, and then, 10 seconds later, one video closes. How can I make it work right?