JavaScript use message box

zhaozj2021-02-16  85

Use a message box

JScript tutorial

Previous page

-------------------------------------------------- ------------------------------

Use warnings, prompts, and confirmation, you can use a warning, confirm, and prompt message box to obtain the user's input. These message boxes are the interface method of the Window object. Since the Window object is located on the top layer of the object level, the full name of these message boxes is not necessary in practical applications (for example, "Window.alert ()"), but the full name is a good note, which helps you remember these messages. Which object is belonging to the frame.

The warning message box Alert method has a parameter, that is, the text string you want to display the user. This string is not an HTML format. The message box provides a "OK" button to close the message box, and the message box is the Mode dialog, that is, the user must turn off the message box first before you can continue. WINDOW.Alert ("Welcome! Please press" OK "to continue.");

Verify that the message box uses the confirmation message box to ask the user "YES - or - No" problem, 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 mode dialog: The user must turn it after the dialog box (click a button) to turn it off to perform the next step. Var trutbetold = WINDOW.CONFIRM ("Click" OK "to continue. Click" Cancel "stop."); if (trutbetold) {WINDOW.Alert ("Welcome to our web page!");} else window.alert ("Goodbye!");

The message box prompt message box provides a text field, and the user can enter an answer in this field to respond to your tips. This message box has a "OK" button and a "cancel" button. If you provide an auxiliary string parameter, the prompt message box will display the auxiliary string as the default response in the text field. Otherwise, the default text is "". Similar to the Alert () and confirm () methods, the PROMPT method will also display a mode message box. The message box must be closed before the user must first continue.

Var aresponse = WINDOW.PROMPT ("Welcome?", please enter your name. ");

转载请注明原文地址:https://www.9cbs.com/read-12492.html

New Post(0)