Example of alert pop-up prompt box in the basic JavaScript tutorial, basic tutorial alert
A prompt box is displayed for the alert command.
This section provides several simple examples for beginners to learn JavaScript. The following code is an example of a pop-up prompt box:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Alert ("I Am a text prompt! ");
</Script>
Save the above Code as alert.html (or alert.htm) in a text editor (such as a WordPad or other advanced Editor, such as EditPlus ). Double-click alert.html to run the file (actually open the file in IE or another browser). The following prompt box is displayed:
Prompt
If you use the IE browser prompt: to protect your security, Internet Explorer has restricted this webpage from running scripts or ActiveX spaces that can access your computer .", Select "blocked content" to allow IE to run the above JavaScript code.
Instance syntax explanation
Below is a simple explanation of the JavaScript syntax in the above example:
<Script type = "text/javascript"> indicates the beginning of JavaScript code. </script> indicates the end. JavaScript code should be placed between the beginning and the end.
Alert ("I Am a text prompt! ") Is the JavaScript code. alert () indicates that a prompt box (as shown in) is displayed, and the code ends in English.
The prompt text in the pop-up box is caused by "" or ''and placed in alert.
Javascript js alert pop-up box
Brother, alert does not belong to JS. It is implemented by calling the system interface. After it pops up, you must click OK to close it or use the task manager.
You can stop the service three seconds later. Instead of using alert, you must define a layer similar to the pop-up warning box to use JS to control it.
In JavaScript, how does one display the alert bullet box with line breaks?
The character in the alert box cannot be manually set to wrap. It can only be automatically wrap when the width is not enough. "\ n" is invalid in alert.