Example of alert pop-up prompt box in the basic JavaScript tutorial, basic tutorial alert

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.