Understand JavaScript (reproduced from w3cschool)

Source: Internet
Author: User
Document directory
  • 1. ecmascript version
  • 2. What is ecmascript conformity?
  • 3. ecmascript support in Web browsers
  • 1. Why is Dom indispensable?
  • 2. Various levels of DOM
  • 3. Other dom
  • 4. Dom support in Web browsers
  • See:

The core ecmascript of JavaScript describes the syntax and basic objects of the language;

Dom describes the methods and interfaces for processing webpage content;

Bom describes the methods and interfaces for interacting with browsers.

Ecmascript, Dom, and BOM

Although ecmascript is an important standard, it is not the only part of JavaScript, of course, it is not the only part to be standardized. In fact, a complete JavaScript implementation is composed of three different parts:

  • Ecmascript)
  • Document Object Model (DOM)
  • Browser Object Model (BOM)

Ecmascript

Ecmascript is not bound to any specific browser. In fact, it does not mention methods used for input and output by any user (this is different from C, it needs to rely on external libraries to complete such tasks ). So what is ecmascript? The ECMA-262 standard (section 2nd) is described as follows:

"Ecmascript can provide core Script Programming capabilities for different types of host environmentsTherefore, the core scripting language is defined separately from any specific host environment ......"

Web browser is a host environment for ecmascript, but it is not the only host environment. In fact, there are countless other environments (for example, the scriptease of nombas, and The ActionScript used by Macromedia in both Flash and Director MX) that can accommodate ecmascript implementation. So what does ecmascript stipulate outside the browser?

In short, ecmascript describes the following:

  • Syntax
  • Type
  • Statement
  • Keywords
  • Reserved Words
  • Operator
  • Object

Ecmascript is just a description that defines all attributes, methods, and objects of the script language. Ecmascript can be implemented in other languages as a functional benchmark. Javascript is like this:

Each browser has its own ecmascript interface implementation, which is then extended, including Dom and BOM (discussed in the following sections ). Of course, there are other languages that implement and extend ecmascript, such as Windows Script Host (wsh), Macromedia in flash and Director MX, and nombas scriptease.

1. ecmascript version

Ecmascript is divided into several different versions, which are defined in a standard called ECMA-262. Like other standards, the ECMA-262 is edited and updated. When there is a major update, a new standard version will be released. The latest ECMA-262 version is the third edition, released in December 1999.

The first version of the ECMA-262 is essentially the same as Netscape's JavaScript 1.1, just removing all browser-related code, and there are also some small adjustments. First, the ECMA-262 requires support for Unicode standards (to support multiple languages ). Second, it requires that the object is platform-independent (JavaScript 1.1 of Netscape actually has different object implementations, for example, the date object depends on the platform ). This is the main reason why JavaScript 1.1 and 1.2 do not comply with the first version of the ECMA-262 specification.

Most updates to the second edition of the ECMA-262 are editorial in nature. This Standard update is intended to be strictly consistent with the ISO/IEC-16262 and has not been specifically added, changed, or deleted. Ecmascript generally does not comply with version 2.

The third edition of ECMA-262 is the first real update to the standard. It provides string processing, error definitions, and numerical output updates. At the same time, it also adds support for regular expressions, new control statements, try... catch exception handling, and some small changes made to internationalize the standard. In general, it marks ecmascript as a real programming language.

2. What is ecmascript conformity?

In ECMA-262, ecmascript conformance has a clear definition. A script language must meet the following four basic principles:

  • Compliant implementations must support all types, values, objects, attributes, functions, and programming languages and semantics as described in the ECMA-262 (ECMA-262, page 1)
  • Compliant implementations must support the Unicode Character Standard (UCS)
  • A compliant implementation can add "Additional types, values, objects, attributes, and functions" that are not specified in the ECMA-262 ". The ECMA-262 describes these additions as new properties for new objects or objects not given in the Specification
  • A compliant implementation can support the "Program and regular expression syntax" that is not defined in the ECMA-262 (meaning it can be replaced or extended with built-in Regular Expression support)

All ECMAScript implementations must comply with the above standards.

3. ecmascript support in Web browsers

Netscape Navigator 1.1, which contains JavaScript 3.0, was released in 1996. The JavaScript 1.1 specification is then submitted to EMCA as a new Standard Draft. With the vigorous popularity of JavaScript, Netscape is very happy to start developing version 1.2. However, there is a problem that ECMA does not accept the Netscape draft. Shortly after Netscape Navigator 3.0 was released, Microsoft released IE 3.0. This version of IE contains JScript 1.0 (Microsoft's own JavaScript
Implementation name), the original plan can be compared with JavaScript 1.1. Then, due to incomplete documents and some inappropriate repetitive features, JScript 1.0 is far from reaching JavaScript 1.1.

Prior to the finalization of the first ECMA-262 version, Netscape Navigator 1.2, which included JavaScript 4.0, was released in 1997, when ECMA-262 standards were accepted and standardized later that year. Therefore, JavaScript 1.2 is not compatible with the first version of ECMAScript, although ECMAScript should be based on JavaScript 1.1.

The next step of JScript is to add JScript 4.0 to IE 3.0 (Version 2.0 is released along with IIS 3.0, but is not included in the browser ). Microsoft vigorously promotes JScript 3.0 as the world's first script language that truly complies with the ECMA standard. At that time, the ECMA-262 was not finalized, so JScript 3.0 suffered the same fate as JavaScript 1.2-it still failed to meet the final ECMAScript standard.

Netscape chooses to upgrade its JavaScript implementation in Netscape Navigator 4.06. Javascript 1.3 makes Netscape fully compliant with the first version of ecmascript. Netscape has added support for the Unicode Standard and made all objects retain the new features introduced in Javascript 1.2 while implementing platform independence.

When Netscape published its source code as the Mozilla project, it was originally planned that JavaScript 1.4 would be embedded in Netscape Navigator 5.0. However, an aggressive decision-completely re-designing the Netscape code from the ground up breaks the work. Javascript 1.4 is only published as a server-side scripting language of the Netscape Enterprise Server and will not be put into the browser in the future.

Today, all mainstream Web browsers follow the third edition of ECMA-262.

The following table lists ecmascript support in most popular Web browsers:

Browser Dom compatibility
Netscape Navigator 2.0 -
Netscape Navigator 3.0 -
Netscape Navigator 4.0-4.05 -
Netscape Navigator 4.06-4.79 Edition 1
Netscape 6.0 + (Mozilla 0.6.0 +) Edition 3
Internet Explorer 3.0 -
Internet Explorer 4.0 -
Internet Explorer 5.0 Edition 1
Internet Explorer 5.5 + Edition 3
Operators' 6.0-7.1 Edition 2
Opera 7.2 + Edition 3
Safari 1.0 +/Konqueror ~ 2.0 + Edition 3
Dom

Dom (Document Object Model) is an application interface (API) of HTML and XML). Dom plans the entire page as a document at the node level. Each part of an HTML or XML page is a derivative of a node. Consider the following HTML page:

This code can be used to draw a node hierarchy chart with DOM:

Dom represents a document by creating a tree, allowing developers to have unprecedented control over the content and structure of the document. You can use Dom APIs to easily Delete, add, and replace nodes.

1. Why is Dom indispensable?

Since IE 4.0 and Netscape Navigator 4.0 support dynamic HTML (DHTML) in different forms, developers are able to modify the appearance and content of a Web page without reloading it for the first time. This is a great leap in Web technology, but it also brings about huge problems. Netscape and Microsoft developed their own DHTML, ending the period in which web developers can access only one HTML page in all browsers.

The industry decides what needs to be done to maintain the cross-platform features of the web. They worry that if Netscape and Microsoft do so, the Web will be divided into two independent parts, each part only applies to specific browsers. Therefore, the W3C (World Wide Web Consortium), a group responsible for specifying web communication standards, began to develop Dom.

2. Various levels of DOM

Dom Level 1 was proposed by W3C in October 1998. It consists of two modules: Dom core and Dom HTML. The former provides an XML-based document structure to access and manipulate any part of the document. The latter adds HTML-specific objects and methods to expand Dom core.

Note that Dom is not proprietary to Javascript. In fact, many other languages have implemented it. However, the DOM in the Web browser has been implemented using ecmascript, which is now a major component of the Javascript language.

Dom Level 1 is just a goal, that is, the structure of the planning document. Dom Level 2 has a wide range of goals. Added support for mouse and user interface events (DHTML has rich support for this), range, and traversal (repeated Dom document execution methods) to the extension of the original Dom, added support for CSS (Cascading Style Sheets) through the object interface. The original Dom core introduced by Level 1 also supports XML Namespaces.

Dom Level 2 introduces several new Dom modules for processing new interface types:

  • Dom view-describes various views of a document (that is, documents before and after CSS styles)
  • DOM Event-interface for Event Description
  • Dom style-operations based on CSS styles
  • Dom traversal and range-interface for describing traversal and Operation Document Tree

Dom Level 3 introduces methods for loading and maintaining documents in a unified manner (including Dom load and save in the new module) and methods for verifying documents (DOM validation, this further expands the Dom. In Level 3, Dom core is extended to support all XML 1.0 features, including XML infoset, XPath, and XML base.

When learning Dom, someone may reference Dom level 0. Note that there is no Dom level 0 standard at all. It is just a historical reference point for Dom (DOM level 0 refers to the original DHTML supported in IE 4.0 and Netscape Navigator 4.0 ).

3. Other dom

In addition to Dom core and Dom HTML, several other languages have released their own Dom standards. These languages are based on XML, and each Dom adds a unique method and interface to the corresponding language:

  • Scalable Vector language (SVG) 1.0
  • Digital Markup Language (MathML) 1.0
  • Synchronous Multimedia Integration Language (SMIL)

Note: If you want to learn more, visit w3school's
SMIL tutorial and SVG tutorial.

In addition, other languages have developed their own Dom implementations, such as Mozilla's XML user interface language (XUL ). However, only the languages listed above are W3C recommendation standards.

4. Dom support in Web browsers

Dom is a standard before it is implemented by a Web browser. The first attempt by IE to use Dom is in version 5.0, but it is not supported by Dom until Version 5.5. IE 5.5 implements Dom Level 1. Since then, ie has not introduced new Dom functions.

Netscape does not introduce Dom support until Netscape 6 (Mozilla 0.6.0. At present, Mozilla has the best Dom support and implements complete Level 1, almost all level 2, and part of Level 3. (The Mozilla development team's goal is to build a browser that is 100% compatible with the standard and their work is rewarded .)

Opera was not added to Dom support until version 7.0, and Safari also implemented most Dom Level 1. Almost all of them are at the same level as IE 5.5. In some cases, they even exceed IE 5.5. However, in terms of Dom support, all browsers are far behind Mozilla. The following table lists the DOM support of common browsers.

Browser Dom compatibility
Netscape Navigator 1.0-4.x -
Netscape 6.0 + (Mozilla 0.6.0 +) Level 1, level 2, level 3 (Part)
Internet Explorer 2.0-4.x -
IE 5.0 Level 1 (minimum)
Internet Explorer 5.5 + Level 1 (almost all)
Operators' 1.0-6.0 -
Opera 7.0 + Level 1 (almost all), level (Part)
Safari 1.0 +/Konqueror ~ 2.0 + Level 1

Note: If you want to learn more about Dom, visit w3school's
HTML Dom tutorial and
Xml dom tutorial.

BOM

IE 3.0 and Netscape Navigator 3.0 provide a feature-BOM (Browser object model), which allows you to access and operate on browser windows. With Bom, developers can move the window, change the text in the status bar, and perform other actions that are not directly related to the page content. What makes BOM unique and often suspicious is thatIt is only a part of JavaScript and has no relevant standards..

Bom mainly processes browser windows and frameworks. However, browser-specific JavaScript extensions are usually considered part of BOM. These extensions include:

  • A new browser window is displayed.
  • Move and close the browser window and resize the window
  • Locating objects with detailed web browser Information
  • Screen Object that provides detailed information about the user's screen resolution
  • Cookie support
  • IE extends BOM and adds the activexobject class. ActiveX objects can be instantiated through JavaScript.

Because there is no relevant BOM standard, Each browser has its own BOM implementation. There are some de facto standards, such as having a window object and a navigation object, but each browser can define its own attributes and methods for these objects or other objects.

See:
  • Window object
  • Navigator object
  • Screen Object
  • History Object
  • Location object

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.