I'm trying to show diffrent urls after a specific time.
I tried this but it looks that only the result of location.href
is considered (as if the function ignores the other lines), can someone please explain why it behaves this way?
var stack = ["https://stackoverflow.com", "https://youtube.com", "website3"];
function myFunction() {
location.href = stack[0];
setTimeout(function() {window.location.replace = stack[1];}, 3000);
setTimeout(function() {window.location.replace = stack[2];}, 3000);
}
<button onclick="myFunction()">change website</button>