The alert box is the simplest one of system dialogs. It may be used to alert user on incorrect information in forms, to display warning on service expiry, to display invalid result from a calculation …and so on. When an alert box pops up the OK button has to be pressed to proceed; thus, it makes the user going through the information it displayed. This method is part of a window object described in details here.
A confirm box dialog displays a message to the user and has an OK and Cancel buttons. It allows user to confirm if an action has to be taken or not. If user clicks OK, true is returned to the script, else if Cancel or X in top corner is pressed, false is returned. This dialog box is used in applications like deleting email, closing a web-page …etc. This method is part of the window object.
confirm (“display message”);
The prompts box dialog prompts an user to input data. It has an OK and Cancel buttons for the user to send the data or cancel it. If OK is pressed, the data is sent to the script, and else if Cancel or X in top right window is pressed, null is returned to the script. They are handy in applications like asking for user name, entering numbers …etc. This method also is part of the window object.
prompt (“display message”);