Is there a way to navigate to the home screen when a js alert is closed?
So I have triggered an alert
.then((message) => alert("Bestellung wird bearbeitet")
& I want that you get redirected to the Home Screen when you press on the close button.
Is there a way to accomplish this behaviour?
I tried adding
window.location.href = 'index.html'
after the alert button, but I get redirected instantly, so the alert button doesn't even appear. But I want to be redirected after the alert button is closed.
The attempt:
function sendEmail() {
Email.send({
SecureToken: "a",
To: "b",
From: "[email protected]",
Subject: "Bestellung",
Body:
"Body"
}).then((message) => alert("Bestellung wird bearbeitet"),
window.location.href = 'index.html');
}
CodePudding user response:
As stated here the second arguments passed to then()
it's the handler for the rejected case. You were passing a second argument using ,
instead of wrapping a sequence of statements in the closure function body.
This is the way for the second instruction to be executed after the user closed the alert dialog:
.then((message) => {
alert("Bestellung wird bearbeitet");
window.location.href = 'index.html';
}