using message boxesUse warnings, prompts, and confirmations
You can use the warning, confirmation, and prompt message boxes to get the user's input. These message boxes are the interface methods of the Window object. Because the Window object is at the top level of the object hierarchy, you do not have to use the full name of these message boxes (for example, "Window.alert ()") in the actual application, but taking the full name is a good note, which helps you remember which object these message boxes belong to.
Warning message box
The alert method has a parameter, which is the text string that you want to display to the user. The string is not in HTML format. The message box provides a OK button to let the user close the message box, and the message box is a modal dialog box, which means that the user must close the message box before proceeding.
Window.alert ("Welcome!" Please press "OK" to continue. ");
Confirmation message box
Use the confirmation message box to ask the user a yes-or-no question, and the user can choose to click the OK button or click the Cancel button. The return value of the Confirm method is true or false. The message box is also a modal dialog box: The user must close the dialog box (click a button) before the next action can be made.
var truthbetold = window.confirm ("Click OK" to continue.) Click Cancel to stop. ");
if (truthbetold) {
Window.alert ("Welcome to our WEB page!") ");
} else Window.alert ("Good-bye!" ");
Prompt message box
The Hint message box provides a text field where the user can enter an answer in response to your prompt. The message box has a "OK" button and a "Cancel" button. If you provide a secondary string argument, the prompt message box displays the auxiliary string as the default response in the text field. Otherwise, the default text is "<undefined>".
Similar to the alert () and Confirm () methods, the Prompt method also displays a modal message box. The user must close the message box before continuing the operation
The prompt () method is used to display a dialog box that prompts the user for input.
Grammar
Prompt (Text,defaulttext)
Parameters |
Description |
Text |
Optional. The plain text to display in the dialog box (instead of the HTML-formatted text). |
DefaultText |
Optional. The default input text. |
Description
Returns NULL if the user clicks the Cancel button of the prompt box. If the user clicks the Confirm button, the text that is currently displayed in the input field is returned.
It will block all user input to the browser until the user clicks the OK button or the Cancel button to close the dialog box. When prompt () is called, execution of the JavaScript code is paused, and the next statement is not executed until the user responds.
This part of the blog from the Internet to another blogger of the park, no infringement, if not carefully violated, please contact me promptly delete, thank you!
The difference between JS alert (), confirm (), prompt ()