The window object provides three methods to display a simple dialog box to users:
① Alert ():Displays a message to the user and waits for the user to close the dialog box.Alert ("Welcome to JavaScript world! ");
② Confirm ():Ask the user to click an OK or cancl button to confirm or cancel the operation.Confirm ("are u sure? ");
③ Prompt ():Request the user to enter a string.Prompt ("input your password ");
Although these three dialog box methods are simple and easy to use, they are well designed to be used as little as possible. Dialog boxes like this are not common functions of the Web mode, and they are now increasingly rare, because Web browsers with higher capabilities support the scripting of the document content. Most users will find that the dialog box generated by the alert (), confirm (), and prompt () methods will damage their browsing experience. Now, the only common application of these methods is debugging: javascript programmers often insert an alert () method into the code.
Both methods confirm () and prompt () generate blocking, that is, they do not return until the displayed dialog box is closed. This means that the Code stops running when a dialog box is displayed. If the document is currently being loaded, it will also stop loading until the user responds with the required input. There is no way to block the blocking of these methods, because their return values are user input, so the method must wait for the user to input before returning.
In most browsers, the alert () method also blocks and waits for the user to close the dialog box.