1var proceed = confirm("Are you sure you want to proceed?");
2if (proceed) {
3 //proceed
4} else {
5 //don't proceed
6}
1 if (confirm("Press a button!")) {
2 console.log("Accepted")
3 } else {
4 console.log("Declined")
5 }
1if (window.confirm("Une nouvelle fenêtre va s'ouvrir.")) {
2 window.open("fenetre.html", "Nouvelle fenêtre", "");
3}
1// The confirm function is used to display a dialog with ok and cancel. Usage:
2
3var content = confirm("Hello"); // The "hello" means to show the following text
4if (content === true) {
5 // Do whatever if the user clicked ok.
6} else {
7 // Do whatever if the user clicks cancel.
8}
9
10// You can also use window.confirm()