alert command pops up a prompt box
To facilitate an intuitive understanding of JavaScript, this section will provide several simple examples for introductory learning of JavaScript. The following code is an example of a pop-up prompt box:
Save the above part of the code as alert.html (or alert.htm) using a text editor (such as WordPad or other more advanced editors, such as EditPlus, etc.). Double-click alert.html to run it (actually use a browser such as IE to open this file), and you will see the following pop-up prompt box:
Tips
If you use IE browser prompt: In order to help protect security, Internet Explorer has restricted this web page from running scripts or ActiveX spaces that can access the computer. ”, then please select “Allow blocked content” to allow IE browser to run the above JavaScript code.
Explanation of syntax with examples
The following is a simple explanation of the JavaScript syntax of the above example:
represents the end. JavaScript code should be placed between this start and end.
alert("I am the prompt text!"); is JavaScript code. alert() means popping up a prompt box (as shown in the picture above), and the code ends with the English ";" symbol.
The prompt text of the pop-up box is enclosed in "" or '' and placed in alert().