Dialog Boxes in JS:

The dialog boxes are used to raise an alert or to give confirmations to user (or) to collect value and displaying that value.

Java Script pop up boxes are 3 types.

1) Alert Box: alert message display to a browser.
2) Confirm Box: Verify or accept some confirm message from user and display on browser.
3) Prompt Box: fetch value from user and display on browser.

1) Alert Box:

Syntax:
alert("text");

Code:



Output:


After clicking button:


2) Confirm Box:

When a confirm box display on browser, the user allow to click either "OK" or "Cancel" to proceed.
Syntax:
confirm("text");

Code:



Output:



After clicking button:




3) Prompt Box:

Syntax:
prompt("Enter some value","default value");

Code:



Output:



After clicking button: