JavaScript DOM Programming Art (second edition) reading notes-(i)

Source: Internet
Author: User

Study and work often through the guidance of the search engine into the blog park, the knowledge of the technical Daniel often sharply to solve the problem that has plagued me for a long time large and small. But has always been to read someone else's blog, he has not moved, until a blog said, from simple to complex to remember reading notes or knowledge summary is a good way to promote technological progress, feel very sensible, after the study of finishing more can remember firm, so recently determined to start my blog garden "life."

Said the simple to complex, as a front-end small and small white, I decided to the classic front-end book reading notes written here, perhaps later forgotten when the return to see there will be an enlightened feeling (laughter).

    • Chapter--javascript Brief History of the first

In previous Web standards, HTML and CSS were often at the core, and later the website approved another technology, and all Web browsers that were compatible with the standard supported it, which is the DOM (the Document Object model: The Documents Objects module). Through the DOM we can add interactivity to the document, just like using CSS to style the document.

The initial DOM is experimental, called the "No. 0 level Dom (DOM levels 0)", does not form a uniform standard initial stage, the No. 0 level Dom common use is to flip pictures and validate form data, until the browser product updates, DOM Lv0 encountered trouble into the dilemma.

Then the birth of DHTML (Dynamic HTML), the meaning is (1) using HTML to mark the page as an element, (2) the use of CSS to set the element style and their display location, (3) The use of JavaScript in real-time control of the page and change style. But the above three points are only theoretical feasible, subject to browser compatibility, there is no unified approach to solve the DOM problem. This makes it possible to distinguish between different browser environments when programming apes write Dom scripts, until 1998, when the World Wide Web introduced a standardized DOM called the "first level Dom"

Until today almost all browsers have built-in support for the DOM, as well as the many new features of the HTML5 DOM, which can eventually be "written once and run everywhere".

    • Chapter II--javascript syntax

The JS code must be executed through the html/xhtml document, which can be performed in two ways:

1. Place JS code between <script> tags in

2, the JS code exists in a separate file with the extension. js, put a <script> tag in HTML, and use the SRC attribute to point to the file, for example <script src = "file.js" ></scirpt>.

But the best way is to put the <script> tag before the last,</body> tag in the HTML document , namely:

   < Body > Body Content ... <   = "File.js" > </scirpt> </body  >

This allows the browser to load the page more quickly (the 5th chapter of the book is discussed in detail).

Every time you change the contents of the. js file, you only need to reload the. html file in the browser to see the effect, this is JS this interpreted programming language and Java, C + + and other compiled language needs compiler different places. JS is directly read into the source code and executed by the browser's JS interpreter.

The JS statement needs to be separated by semicolons in the same line, and comments can be commented using "//" or "/* ..."/"* *"; variable declarations can be individually, or can be declared multiple at once, variable naming is case-sensitive, and the camel-named method is recommended. In JS, single or double quoted strings are semantically identical in the weakly typed language of JS; data types contain strings, numeric values, Boolean values, arrays (array subscripts starting from 0), objects.

If the var keyword is used in a function, that variable is treated as a local variable that exists only in the context of the function, whereas if VAR is not used, that variable is treated as a global variable, and if a global variable with the same name already exists in the script, This function will change the value of that global variable.

An object is a self-contained collection of data, and the data contained in the object can be accessed in two ways-properties, methods. (1) A property is a variable that belongs to a particular object, and (2) is a function that only a particular object can call. So an object is a data entity that is composed of a combination of properties and methods. These are built-in objects, such as the math object and the Date object, that belong to JS. In addition, browser-predefined objects are called host objects, such as form, Image, element, and so on. The Document object is also a host object that is used to obtain information about any element on a Web page.

JavaScript DOM Programming Art (second edition) reading notes-(i)

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.