Alert message box alert
The alert method has one parameter, which is the text string you want to display to the user. The string is not in HTML format. The message box provides an "OK" button for the user to close the message box, and the message box is a modal dialog box, that is, the user must close the message box before continuing.
window.alert("Welcome! Please press "OK" to continue.");
2. Confirm message box confirm
Use the confirmation message box to ask the user a "yes-or-no" question, and the user can choose to click 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 respond to the dialog box (click a button) to close it before proceeding further.
var truthBeTold = window.confirm("Click "OK" to continue. Click "Cancel" to stop.");
if (truthBeTold) {
window.alert("Welcome to our Web page!");
} else window.alert("Goodbye!");
3. Prompt message box prompt
The prompt message box provides a text field in which the user can enter an answer in response to your prompt. The message box has an "OK" button and a "Cancel" button. If you provide an auxiliary string parameter, the prompt message box will display the auxiliary string in the text field as the default response. Otherwise, the default text is "
Similar to the alert() and confirm() methods, the prompt method will also display a modal message box. The user must close the message box before continuing
var theResponse = window.prompt("Welcome?","Please enter your name here.");
More alert(), For articles on the difference and usage of confirm() and prompt(), please pay attention to the PHP Chinese website!