
JavaScript Popup Boxes
29 November, 2023
18
18
0
Contributors
JavaScript popup boxes are simple dialog boxes that appear on a web page. There are three main types of popup boxes in JavaScript: alert, confirm, and prompt.
- Alert Box
- An alert box is used to display a message to the user.
- It only has one button, usually labeled "OK."
alert("this is an alert message!");
- Confirm Box
- A confirm box is used to ask the user for confirmation (yes or no).
- It has two buttons, typically labeled "OK" and "Cancel" like yes or no
let result = confirm("u sure u wanna delete this");
if (result === true) {
//user clicked OK
// perform the delete operation
} else {
// user clicked Cancel
// do nothing or leave it
}
- Prompt Box
- A prompt box is used to get input from the user.
- It has an input field for the user to enter data.
let age = prompt ('enter your age ')
javascript
programming
js
developer
languages
intermediate