"JavaScript advanced Programming" reading notes

Source: Internet
Author: User
Tags cdata

Recently, began to learn JavaScript, can be described as rookie rookie, although the start is very late, but I know that learning a language cannot be done overnight, but also to come down, "JavaScript Advanced Program Design" is a very good JavaScript primer book, So I decided to study it carefully first. Let's learn the preface and the first two chapters today.

1. A brief History of JavaScript

JavaScript was born in 1995, is Netscape Company's Brandon Aichi began to organize, and developed jointly with Sun, and in order to catch the hot Java of the ride, and named JavaScript, in fact, it does not have a half-penny relationship with Java. JavaScript1.0 has been a huge success, which has caught Microsoft's attention, and Microsoft has used JavaScript in its own ie, just to avoid the patent dispute and call it JScript. The contention between the two browsers led to the lack of a standardized use of JavaScript, which led directly to the 1997, the European Association of Computer Manufacturers (ECMA), modelled on JavaScript1.1, after months of efforts to define a name called ECMAScript (pronounced " Ek-ma-script ") standard, which has standardized JavaScript.

2, the implementation of JavaScript

A complete JavaScript implementation consists of the core (ECMAScript), the Document Object Model (DOM), the browser object model (BOM) three parts, and then, the next, they are briefly described.

①ecmascript. ECMAScript does not have a direct relationship with the web, and the language itself does not contain input and output definitions, and the Web environment is just one of the hosting environments that the ECMAScript implements. It mainly specifies the following components of the language: syntax, type, statement, keyword, reserved word, operator, object. The 1997 ECMA set the standard for JavaScript, and by the year 2008, the major browsers have implemented JavaScript compatibility.

The ② Document Object Model (DOM) Document Object model is an application programming interface (API) for Xhml but is extended for HTML, and the DOM maps the entire page into a multi-tiered node structure. It is presented by the consortium. The concrete structure behind it will be learned ...

③ Browser object model (BOM) fundamentally, the BOM only handles browser windows and frames, but it's customary to count JavaScript extensions as part of a BOM. And HTML5 's appearance, the BOM details into the standard, making it more compatible.

3. How to use JavaScript in HTML

The main way to use JavaScript in HTML is with the help of <script> tags, and there are two ways to use <script> elements: embed JavaScript code directly in the page and include external JavaScript files. The latter is more recommended, and the internal JavaScript code will be interpreted from top to bottom, and the other code in the page will not be executed until the code inside the <script> is not interpreted ~ which leads to the JavaScript code generally placed in the <body The end of the > tag;

If you want to include an external JavaScript file, the SRC attribute must have the format:

<script type = "Text/javascript" src = "example.js" ></script>

The src attribute of JavaScript can also contain JavaScript files from external domains (similar to the tag), at which point the SRC attribute points to a full URL address.

It is also important to note that the,<script> tag also has two properties for external JavaScript files, and async and defer may be used to indicate that the script should be downloaded immediately, which is a deferred script (defer= "defer"). Indicates that the script can be downloaded immediately, and can be deferred until the document is fully parsed and then executed.

4. The application of JavaScript in XHTML, XHTML is more stringent than HTML syntax requirements, such as < (less than the number) will be mistaken for a new label, this time, we can use a CDATA fragment to contain the JavaScript code, for example:

<script type = "Text/javascript" ><![cdata[function Compare (b) {    if (a < b) {        alert ("A is Less than B ");     }    else{        alert ("A is Greater Thanb");    }}]]></script>  

5. Special case:<noscript> early morning browsers do not support scripts, which can be used to display content in browsers that do not support JavaScript (or scripts are disabled) by using the <noscript> tab.

JavaScript Advanced Program Design reading notes

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.