Popup boxes

JavaScript introduced three dialog boxes that work well enough for alerting, confirming and prompting for values.

  1. alert()
  2. confirm()
  3. prompt()

When we work with client side, these dialog boxes are helpful to raise and alert, or to get confirmation on any type of input from the users

Alert Box ( JavaScript Message Box )

Javascript alert box

Syntax

Alert Box is the Javascript message box that inform or alert the user by displaying some messages in a small dialogue box. It is important to note that the alert() method doesn't have an object name in front of it, because the alert() method is part of the window Object. It is often used if you want to make sure information display to the user. Whenever an alert box pops up, the user will have to click "OK" button to proceed to next step



Confirm Box

Javascript confirm box

Javascript confirm box is often used if you want the user to make a choice. When Javascript pops up a confirm box , the user will have to click either "OK" or "Cancel" to proceed the next step. Two different actions will occur depending on which button the user clicks. If the user clicks "OK", the confirm box returns true and if the user clicks "Cancel", the Confirm box returns false



Prompt Box

Javascript prompt box

Javascript Prompt Box is often used if you want the user to enter an input value before proceed to the next step. When Javascript display prompt box , the user will have to click either "OK" or "Cancel" to proceed after entering an input value. If the user clicks "OK" the box returns the input value and if the user clicks "Cancel" the box returns null