Alert prompt confirm part 3

Confirm Box



confirm box is often used to have the user verify or accept something.
When a confirm box pops up, the user must click either OK or Cancel to proceed.
If the user clicks OK, the box returns true. If the user clicks Cancel, the box returns false.

Example:
var result = confirm("Do you really want to leave this page?");
if (result == true) {
alert("Thanks for visiting");
}
else {
alert("Thanks for staying with us");
}
Try It Yourself

Result:
The result when the user clicks OK:
The result when the user clicks Cancel:
Do not overuse this method, because it also prevents the user from accessing other parts of the page until the box is closed.

Comments

Popular posts from this blog

String Operators

Introducing object part 3

The math object part 2