Chapter One: Introduction to JavaScript
The 1.JavaScript was born in 1995, when its main purpose was to handle some of the input validation operations previously handled by server-side languages such as Perl. JavaScript is now a scripting language designed to interact with Web pages.
Note: Netscape (Netscape) research and Development, Java is the development of the Sun Company, formerly known as LiveScript, in order to catch the media stir Java's ride, renamed to JavaScript
2. Microsoft launched Jsript's and Netscape's JavaScript competition, finally Microsoft wins. The ECMA specified and renamed the ECMAScript.
3. Although JavaScript and ECMAScript are often used to express the same meaning, JavaScript has a much larger meaning than the one specified in ECMA-262. A complete JavaScript implementation is made up of the following three different parts.
(1) core (ECMAScript), defined by ECMA-262, provides core language functions.
(2) Document Object Model (DOM), which provides methods and interfaces for accessing and manipulating Web page content.
(3) A Browser object model (BOM) that provides methods and interfaces for interacting with the browser.
4.ECMA-262 provides the following components: syntax, type, statement, keyword, reserved word, operator, object
5. By the year 2008, the five major web browsers (Ie,firefox,safari,chrome and opera) were all compatible with ECMA-262. Of these, all browsers support ECMAScript Third edition is generally good, and the support of ECMAScript 5 is more and more high, but the support for DOM is different from each other. For a BOM that has been formally incorporated into the HTML5 standard, although a browser implements some well-known common features, other features may vary by browser.
Chapter Two: using JavaScript in HTML
1.html4.01 defines 6 properties for <script>: Async (optional), CharSet (optional), defer (optional), language (deprecated), src (optional), type (optional)
2. Because according to the rules of parsing embedded code, when the browser encounters the string "</script>", it is considered to be the end of the </script> tag. This problem can be solved by escaping the character "/". <\/script>
3. Regardless of the code, as long as the defer and async attributes do not exist, the browser will parse the <script> elements once in the order they appear in the page.
4. Insert JavaScript into the HTML page to use the <script> element, use this element to embed JavaScript in an HTML page, mix scripts with tags, or include external JavaScript files
The main areas we need are:
- When you include an external JavaScript file, you must set the SRC attribute to the URL of the appropriate file. This file can be either a file located on the same server as the page containing it, or a file in any other domain.
- All <script> elements are parsed sequentially in the order in which they appear in the page. Without using the defer and async attributes, the code in the following <script> elements will be parsed only after parsing the previous <script> element's code.
- Since the browser resolves the code in the <script> element that does not use the Defer property, and then parses the subsequent content, the <script> element should generally be placed at the end of the page, that is, after the main content,</body> the front
- Using the Defer property allows the script to be fully rendered in the document only to be executed again. Deferred scripts are always executed in the order in which they are specified.
- Use the Async property to indicate that the current script does not have to wait for other scripts or block document rendering. There is no guarantee that asynchronous scripts execute in the order they appear in the page
In addition, you can use the <noscript> element to specify alternative content that is displayed in browsers that do not support scripting. However, when scripting is enabled, the browser does not display anything in the <noscript> element.
The third edition of JavaScript Advanced Programming, Chapter 2, JavaScript Introduction and HTML reading notes