DOM and BOM difference

DOM, DOCUMENT, BOM, WINDOW difference
DOM API documentation for the operation that appears, document it is an object of;
BOM is to operate API browser appears, window it is an object of.

BOM is a content browser object model, DOM Document Object Model, the former is to operate the browser itself, which is the browser (which can be seen as a container) within the operating


 

 


Owned DOM tube:

E area (the document is what you say it. By the web developers worked hard to write out a file folder, there are index.html, CSS, and JS what the hell is deployed on the server, we can use the address bar of the browser, enter the URL then Enter to load the document into local, browse, view source code, etc. right.

 

BOM return pipe:

Area A (browser tabs, address bar, search bar, bookmarks bar, close the window and amplify buttons, menu bar, etc.)

Area B (the browser's right-click menu)

C region (the document loading status bar display http status code, etc.)

Area D (scroll bar scroll bar)

 

The DOM 2.1
the DOM stands for Document Object Model, which is the document object model. XML is for tree-based API. A method and interface processing web content is HTML and XML API, DOM into planning the entire page document consisting of a node level.

The DOM defines a HTMLDocument and HTMLElement as the basis of this realization, that in order to operate in this HTML programming methods (such as add certain elements, modify the content of the element, delete some elements), we put this seen as a HTML object tree (DOM tree), and inside itself all things such <div> </ div> tags which are regarded as one object, each object is called a node (node), the node will be understood that the DOM Object of all the parent class.

 

    DOM what's the use? Is to HTML elements in the operation, for example, we want to JS by the title of this page is changed, so that you can direct the:

document.title = 'how to make love';

This API makes changing web page after web page is downloaded to the browser content possible.

 

2.2 document

When downloaded to a web browser, usually HTML, this is called HTML document (of course, this is also a node DOM tree), you can see from the chart, document is usually the root of the whole DOM tree. This document contains the title (document.title), URL (document.URL) and other properties can be accessed directly in JS.

In a browser window may have multiple document, for example, via an iframe loads a page, each of which is a document.

In JS, you can access its child nodes (in fact, any node can) through the document, such as

document.body;document.getElementById('xxx');

 

BOM 2.3
BOM is the Browser Object Model, the browser object model.

DOM just said to operate interface documentation appears, the interface that is actually the name suggests BOM to control the behavior and appearance of the browser.
What browsers can do it? For example, to jump to another page, forward, backward, and so on, the program may need to obtain parameters like the size of the screen.
So BOM to solve the interface of these things occur. For example, we want the browser to jump to another page, you need only

location.href = "http://www.xxxx.com"; this is the location of an object in the BOM.

 

Because of the BOM window contains a document, so you can use direct document properties window object, by document attributes can access, retrieve, modify XHTML document content and structure. Because the document object is the root DOM (Document Object Model) model.

It can be said, BOM contains a DOM (Object), the browser provides access to a BOM give out the object, and then accessed from the BOM object to the DOM object, which can be operated js browsers and browser to read the document.
---------------------
Author: Chen Hong Kong Swallow
Source: CSDN
Original: https: //blog.csdn.net/qq877507054/article/details/51395830
copyright Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/HoneyTYX/p/11269748.html