Home>Article>Web Front-end> How to pop up a dialog box in javascript
How to implement the javascript pop-up dialog box: 1. Set the dialog box through the alert() method; 2. Set the dialog box through the confirm() method; 3. Set the prompt box through the prompt() method.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
Three pop-up dialog boxes in JavaScript
Friends who have studied js will find that we have used the alert() method and prompt() in some instances method, prompt() method, they both pop up a dialog box on the screen and display the content in brackets on it. Using this method makes the interactivity of the page more exciting. In fact, we often simply This type of dialog box is often used in two-way communication between users and applications. The three dialog boxes of avascript are obtained by calling the three methods alert(), confirm() and prompt() of the window object. These dialog boxes can be used to complete the input and output of js and realize js that can interact with the user. code. Today, the editor will briefly introduce the three pop-up dialog boxes in js. The editor will first explain these methods in detail separately, and then compare these methods. Okay, let’s start our js journey. `(*∩_∩*)′......
The first one: alert() method
The alert() method is these three dialogues The easiest one to use in the box, it can be used to simply and clearly display the text information in the alert() brackets in the dialog box. We call it an alert dialog box. The information to be displayed is placed in the brackets. The dialog box contains a Confirm button that the user can simply click to close the dialog box after they have finished reading the displayed information.Let’s look at an example of using the alert() method. The code is as follows:
编写html页面
Execute the above small example to pop up a dialog on the page Frame and display the sentence "First line: Ancient trees withered under the rocks and rocks", as shown below:
Next, click the "Confirm" button and then the second dialog box will be displayed and"The girl beside the white water spring is wonderful!", the effect is as follows;
# pops up a dialog box on the page and display a sentence "Shanglian: Ancient wood under the rocky rock", After clicking the "Confirm" button, the second dialog box will be displayed and "The girl beside the white water spring is wonderful!" Let's analyze this small example:
a. In