Alert, Prompt, Confirm
Alert, Prompt, Confirm
alert:
It shows the message and waits for the user to press "OK".
prompt:
The function "prompt" accepts two arguments:
It shows a modal window with a text message, an input field for the visitor, and
the buttons OK/Cancel.
The second parameter is optional: the initial value for the input field.
confirm:
The syntax:
result = confirm(question);
The function confirm shows a modal window with a question and two buttons: OK and
Cancel.
The result is true if OK is pressed and false if Cancel is pressed.
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 of the methods above:
1. The exact location of the modal winodw is determined by the browser.
Usually, it's in the center.
2. The exact look of the window also depends on the browser. We can't modify
it.