in the first JavaScript video summary blog, a macro understanding of JavaScript was made. Among them, I do not know if you can remember, the core part of JavaScript include Which? The core of JavaScript consists of three main parts:1.ECMAScript, if you want to know more about it, you might as well look at Baidu. 2.BOM (Browser object model)3.DOM (Document Object Model )This blog is mainly about the following two core parts to do a simple summary, the two look similar, in fact, has a completely different role. I. BOMthe Browser object model, which provides many objects for accessing the browser's functionality. It lacks specification, each browser has its own different functions or ideas, but there are still some common objects between browsers. Here are three common objects: window, location, and history. 1.window Objects
The core object of the BOM is window, which represents an instance of the browser. Video, the main introduction to us is the above 4 usage. In addition, the Window object contains many properties and methods, and it is sufficient to understand some common ones. In particular, properties and methods under window can be called using window. Properties, window. method () or direct properties, methods (). such as: Window.alert () and alert () is a meaning. 2.location object location is one of the BOM objects that provides information about the documents loaded in the current window and provides some navigational features. Here is an enumeration of some of the methods and properties that are commonly used:
The 3.history object History object is a property of the window object that holds the user's online record, from the moment the window is opened.
After we have a clear understanding of the BOM, let's continue to summarize the DOM, and finally compare and contrast them, there is no connection between them. two. The DOM Document Object model depicts a hierarchical node tree that runs a developer to add, remove, and modify portions of a page. We see in the browser HTML page, in fact, it is a document behind, from the head, title, body and other structures. In the DOM, we call each component "node", and here's a complete tree of nodes:
And we are not unfamiliar with the DOM behind the node tree:
Once we have a sense of the whole DOM, let's look at the details of the node:
The above knowledge, do not need us to remember, in the process of use we will naturally mastered. Like the previous project, often use the getElementById () method, so now look is also feeling particularly cordial. three. BOM and Dom through the above learning summary, it is not difficult to find that there is a difference between the BOM and the DOM: 1.BOM lacks standards, and the DOM standard is the one. 2.BOM is closely related to the browser, and the DOM is closely related to HTML or XML documents. the fundamental object of 3.BOM is the Window object, and the underlying object of the DOM is the document object. from the Internet to find some relevant information to read, many places say that they have no relationship between the two, and they feel that their connection is very close. before also said, we see a page, it is actually contains a row of DOM document code, so I think the fundamental object of the DOM is actually the BOM of the fundamental object of the sub-object, is also a property. See:
Four. Learning experience Initially, I originally wanted to tell the BOM and DOM knowledge separately written two blog, because when watching the video, did not find that they have any connection between the two. But began to write, start their own summary of the process, found that they can also establish a certain relationship between two. Instead of summing up, it's better to think more, find more, connect more, and put them together to learn.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"JavaScript" BOM and Dom