The alert command pops up a prompt box
To facilitate an intuitive understanding of JavaScript, this section will provide several simple examples for JavaScript introduction. The following code is an example of a pop-up prompt box:
The code copy is as follows:
<script type="text/javascript">
alert("I am the prompt text!");
</script>
Save some of the code above 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 IE and other browsers to open this file), and you will see the following pop-up prompt box:
hint
If using IE browser tip: To facilitate security protection, Internet Explorer has restricted this webpage from running scripts or ActiveX spaces that can access your computer. ”, then select “Allow blocked content” to allow the IE browser to run the above JavaScript code.
Example syntax explanation
Here is a simple explanation of the JavaScript syntax of the above example:
<script type="text/javascript"> represents the beginning of JavaScript code, and</script> represents the end. JavaScript code should be placed between the beginning and the end.
alert("I am prompt text!"); is JavaScript code. alert() means a prompt box pops up (as shown in the picture above), and the code ends in English; means.
The prompt text of the pop-up box is caused by "" or '' and placed in alert().