This article mainly introduces the example of the alert pop-up prompt box in the basic JavaScript tutorial. The focus of this article is to explain the basic syntax and basic usage of JavaScript. Friends in need can refer to the
alert command pop-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:
<script type="text/javascript"> alert("我是提示文字!"); </script>
Save the above part of the code as alert.html using a text editor (such as WordPad or other more advanced editors, such as EditPlus, etc.) (or alert.htm). 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:
Prompt
Tips if you use IE browser: In order to protect security, Internet Explorer has restricted this webpage 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 example syntax
The following is the above example A simple explanation of JavaScript syntax:
represents the end of JavaScript code. 🎜>alert("I am the prompt text!"); is the JavaScript code. alert() means popping up a prompt box (as shown in the picture above). The code ends with the English ";" which means the prompt text of the pop-up box. "" or '' and put it in alert().