Introduction to JavaScript--add to (X) HTML documents and JavaScript variables

Source: Internet
Author: User

1. JavaScript is a programming language specifically designed to add interactivity to Web pages, and its code is usually embedded in a Web page.

JavaScript is an interpreted language that does not require pre-compilation to perform

JavaScript is a scripting language designed to be used to program Web pages.

2, the role of javascript:

(1) Full control of all elements in an HTML page

(2) You can add dynamic text to an HTML page

(3) Responding to events generated by users when they use the Web page

(4) To verify the data entered by the user

(5) Detecting the visitor's browser

(6) To create cookies

3, JavaScript technology system contains the content:

(1) Core syntax: Data types, variables, constants, operators, statements, etc.

(2) native objects and built-in objects

(3) Browser object model BOM

(4) Document Object Model DOM

(5) Event handling model

4. Add JavaScript to XHTML:

(1) Embed JavaScript statements directly in XHTML using the <script> elements, either in the

(2) Link the external javascript source file to the XHTML document through the SRC attribute of the <script> element.

such as: <script type= "Text/javascript" src= "Js.js" >

if the JS source file that you want to link is not in this XHTML Web page folder, you should jump out of this folder and go to the folder where the JS source file is located. To use: <script type= "Text/javascript" src=". /hello/js.js"(.. means to jump out of the current folder, enter the Hello folder, link the JS source file named Js.js)

(3) Add in line. such as the onclick

<div onclick= "alert (' Bullet box content ')" > This is an example of adding JS in line <div> (the alert statement represents a bullet box whose contents are the contents of a bullet box)

5. JavaScript variables: Variables in JavaScript are defined with VAR plus variable names. Because JavaScript is weakly typed, there is no need for explicit data type declarations when defining variables, and variables are not necessarily initialized. For example: var A; A variable is declared. You can assign a value to a variable.

The naming standard for variable names: numbers, letters, and underscores, which cannot begin with a number, usually without an underscore. The variable name cannot be the same as the keyword.

JavaScript retains a complete list of keywords:

Break else new Var case finally return void Catch for switch while continue function this default if THR ow Delete in try does instanceof typeof abstract enum int short Boolean export interface static by TE extends long super Char final native synchronized class float package throws const Goto p Rivate transient debugger implements protected volatile double import public

Introduction to JavaScript--add to (X) HTML documents and JavaScript variables

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.