Answers for "window.confirm example"

1

javascript window confirm

// window.confirm opens a confirmation box with two buttons; 'Ok' or 'Cancel'
window.confirm("Message");
// window.confirm returns a boolean, true or false, based on whether the user pressed 'Ok' (which will result in true) or 'Cancel' (which will result in false)
if (window.confirm("Message")) {
  console.log("'Ok' was pressed");
} else {
  console.log("'Cancel' was pressed");
}
Posted by: Guest on December-16-2021
0

js confirm

// The confirm function is used to display a dialog with ok and cancel. Usage:

var content = confirm("Hello"); // The "hello" means to show the following text
if (content === true) {
  // Do whatever if the user clicked ok.
} else {
  // Do whatever if the user clicks cancel.
}

// You can also use window.confirm()
Posted by: Guest on August-10-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language