JavaScript Foundation and Enhancement of AJAX Foundation (1)

1. What is JavaScript

  JavaScript is an object-based and event-driven scripting language with security features. The purpose of using it is to link multiple objects in a Web page together with HTML hypertext markup language and Java scripting language (Java applet) and interact with Web clients. Thereby, it is possible to develop client-side applications and the like. It is implemented in standard HTML language by embedding or calling in. It appears to make up for the shortcomings of the HTML language, it is a compromise choice between Java and HTML.

Second, the difference between JavaScript and Java

  Although JavaScript and Java are closely related, they are two different products developed by the two companies. Java is a new generation of object-oriented programming language launched by SUN, especially suitable for the development of Internet applications; while JavaScript is a product of Netscape, its purpose is to extend the functions of Netscape Navigator, and it can be embedded in Web pages. Object-based and event-driven interpreted language, its predecessor is Live Script; and Java's predecessor is Oak language.

3. Write your first JavaScript program

  Below we use an example to write the first JavaScript program. It can be used to describe how JavaScript scripts are embedded in HTML documents.

test1.html document:

<html>

<head>

<Script Language ="JavaScript">

alert("hello world");

</Script> 

</Head>

</Html>

4. Various objects

  

  Window Object (Windows)

    The Window object is at the top of the object hierarchy, and it provides methods and properties for dealing with the Navigator window.

  Document object (Document)

    The document object contains objects that work with document elements (elements), encapsulating these elements for programmers to use.

  Programmers can use these objects to control and process events in the WWW browser environment. In JavaScript, it provides very rich internal methods and properties, thus reducing the work of programmers and improving programming efficiency. This is the fundamental difference between object-based and object-oriented. Among these object systems, the document object is very important, it is located at the lowest level, but it plays a key role in realizing the information interaction of Web pages. Therefore it is the core part of the object system.

 

5. Object function and its role

1. Three main objects in document

There are mainly three most important objects in the document: links, anchor, form, etc.:

(1) anchor anchor object:

The anchor object refers to the object generated when the <A Name=...> </A> tag exists in the HTML source code. It contains all the anchors information in the document.

(2) Links object

  A link object refers to a hypertext or hypermedia element tagged with <A Href=...> </A> as a specific URL.

(3) Form object

  The form object is an element of the document object. It contains object storage information in various formats. It can be used to write programs in JavaScript scripts for text input, and can be used to dynamically change the behavior of the document. There can be multiple identical forms on the same page through the document.Forms[] array. Using the forms[] array is much more convenient than using the form name.

Example: The following is an example of using a form array and form name. The program makes the field contents in the two forms consistent.

Test6_1.htm

<Html>

<head>

</head>

<body>

<form >

<input type=text onChange="document.my.elements[0].value=this.value;" >

</form>

<form NAME="my">

<input type=text onChange="document.forms[0].elements[0].value=this.value;">

</form>

</body>

</html>

  Which uses the OnChnge event (fired when the content of the form changes). The first uses the form name to identify my, and the second uses the form array Forms[]. The effect is the same.

 

2. The attribute attribute in the document object

  The attribute property in the document object is mainly used to control the format of the relevant color and the relevant document title, the URL of the original document of the document, and the date of the last update of the document when referencing the Href mark. The main meanings of this part of the elements are as follows:

(1) Link color: alinkcolor

This element is mainly used, when a link is selected, the color of the link object itself is changed as specified by alinkcolor.

(2) Link color: linkcolor

When the user links with <A Href=...> Text string </A>, the color of the Textstring will be updated according to the color specified by Linkcolor.

(3) Color after browsing: VlinkColor

This property represents the color of links that have been viewed and stored as viewed.

(4) Background color: bgcolor

This element contains the color of the document background.

(5) Foreground color: Fgcolor

This element contains the foreground color of the text in the HTML document.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325832870&siteId=291194637