please click here for more wordpress cource
JavaScript provides three types of dialog boxes: alert, prompt, and confirm. These dialog boxes can be used to interact with users and get their input.
- Alert Dialog Box: The alert dialog box is used to display a message to the user. It has only one button that says “OK”. To create an alert dialog box, use the
alert()
method.
Example:
alert("Hello World!");
- Prompt Dialog Box: The prompt dialog box is used to get input from the user. It displays a message, a text input field, and two buttons: “OK” and “Cancel”. To create a prompt dialog box, use the
prompt()
method.
Example:
let name = prompt("What is your name?");
alert("Hello " + name + "!");
- Confirm Dialog Box: The confirm dialog box is used to get confirmation from the user. It displays a message and two buttons: “OK” and “Cancel”. To create a confirm dialog box, use the
confirm()
method.
Example:
let result = confirm("Do you want to proceed?");
if (result == true) {
alert("You clicked OK!");
} else {
alert("You clicked Cancel!");
}
Note that these dialog boxes are not customizable and have a default appearance. To create custom dialog boxes, you can use HTML and CSS and display them using JavaScript.