Dialog boxes in JavaScript

In this article, you will learn the different types of dialog boxes in JavaScript. The dialog boxes are mostly used to show an alert message, get user confirmation, get user input.

Different types of dialog boxes in JavaScript

  1. Alert dialog box
  2. Confirmation dialog box
  3. Prompt dialog box

1. Alert dialog box

The alert() method is used to display an alert box with a message. The dialog box will block the browser until you click the OK button.

Output:

Alert Box - Clue Mediator
Alert Box – Clue Mediator

2. Confirmation dialog box

The confirm() dialog box is used to get a confirmation for specific user action.

Output:

Confirm Box - Clue Mediator
Confirm Box – Clue Mediator

3. Prompt dialog box

The prompt() dialog box that can get the input from the user. This will return the null value when you click on the Cancel button.

Output:

Prompt Box - Clue Mediator
Prompt Box – Clue Mediator

We can also pass the default value in the input field as a second parameter of the prompt dialog.

I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

1 Response

  1. Virtual Local Numbers says:

    In it something is. Clearly, thanks for the help in this question.

Leave a Reply

Your email address will not be published. Required fields are marked *