And the difference between the role of the window object alert, confirm, prompt the

There are three modes message box, they are alert (), confirm () and prompt ().

1, alert () - warning message box
alert process only one parameter, the user want to display the contents of a text string. The string is not HTML format. The message box provides an "OK" button allows the user to close the message box and the message box is modal, that is, the user must first click OK to close the message box before you can proceed.

2, confirm () - confirmation message box
confirmation message box to ask the user a "Yes" "or" "no" questions, and the user can choose to click "OK" button or click "Cancel" button. return value of true or false confirm methods. The message box is a modal dialog box, the user must respond to the dialog box, click a button to turn it off after to the next step.

3, prompt () - messageboxes
prompt message box provides a text field, the user can enter a response to the content in this field. The message box has an "OK" button and a "Cancel" button. If the user provides a string parameter, the prompt message box will display the contents of the character string in the text field as a default response. Otherwise, the default is "undefined". And alert () and confirm () method analogous, prompt method of a modal message box is also displayed. The user must close the message box after clicking before proceeding.

Guess you like

Origin www.cnblogs.com/hrhr/p/11131271.html