shows a message
The mini-window with the message is called a modal window. The word 'modal' means that the visitor can't interact with the rest of the page, press other buttons, etc, until they have dealt with the window.
shows a message asking the user to input text. It returns the text or, if Cancel button or Esc is clicked, null.
The function prompt accepts two arguments.
result = prompt(title, [default]);
It shows a modal window with a text message, an input field for the visitor, and the buttons OK/Cancel.
*[]: denote that the parameter is optional, not required.
title : The text to show the visitor.
default : An optional second parameter, the initial value for the input field.
The visitor can cancel the input by pressing Cancel or hitting the Esc key, then we get null as the result.
shows a message and waits for the user to press 'OK' or 'Cancel'. It returns true for OK and false for Cancel/Esc.
result = confirm(question);
All these methods are modal: they pause script execution and don't allow the visitor to interact with the rest of the page until the window has been dismissed.
There are two limitations shared by all the methods above.