Introduction to JavaScript and basics (1)

Source: Internet
Author: User

1. What is JavaScript-it is a scripting language that requires a host file, and its host file is an HTML file.

JavaScript is a scripting language that is more complex than HTML. But even if you don't know programming before, don't worry, because JavaScript is written in the form of the source code, that is, you see a page in a comparison of the JavaScript code, you can also use, just copy, and then put in your Web page. Because it is possible to draw on and reference the Code of good Web pages, JavaScript itself becomes very popular and is widely used. People who did not know how to program, more reference JavaScript sample code, also can quickly get started.

2. Its usage:

In the HTML position has three blocks: 1), head inside 2), body inside 3),

<script language= "JavaScript" > code must be placed inside </sceipt>

Simple example:

<body>

3. Three common dialog boxes

1), alert ("") warning dialog box, the role is to pop up a warning dialog;

Alert ("You have selected: OK");

2), confirm ("") determines the dialog box, the function is to pop up a selection of the OK dialog box, click OK after it returns True, click Cancel to return False, the available variables to receive.

Confirm (Do you really want to delete it?) );

3), prompt ("text to display", "value")-------value represents what is displayed by default in the text box

function pops up a dialog box that allows you to enter content. Click Cancel to return "Null".

Prompt ("What's your name, please?") "," and so a story ");

4), JavaScript reserved word

javascript has many reserved words that cannot be used as identifiers.   

when loading scripts, using reserved words can cause compilation errors.  

Break function Return Var Case
Delete If Switch Else void
Catch Do Inch This While
Const instanceof Throw With Continu
Finally Let Try Debugger For
New typeof


Introduction to JavaScript and basics (1)

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.