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)