Home > Web Front-end > HTML Tutorial > The difference and relationship between BOM and DOM_html/css_WEB-ITnose

The difference and relationship between BOM and DOM_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:44:58
Original
1434 people have browsed it

BOM

1. BOM is the abbreviation of Browser Object Model, which is the browser object model.

2. There is no relevant standard for BOM.

3. The most fundamental object of BOM is window.

As can be seen from 1: BOM and browser are closely related. Many things in the browser can be controlled through JavaScript, such as opening a new window, opening a new tab (tab), closing the page, setting the webpage as the homepage, or adding it to favorites, etc... The objects involved are BOM.

As can be seen from 2: Since there is no standard, different browsers may require different implementation methods to implement the same function. For the functions mentioned above, different browsers may require different JavaScript codes to implement the functions.

For example, adding a favorite function:

IE browser: window.external.AddFavorite(url,title);

FireFox browser: window.sidebar.addPanel (title, url, "");

So when writing this piece of JavaScript code, you must consider browser compatibility.

Although there is no set standard for BOM, the JavaScript codes for common functions of various browsers are still similar. There are actually default standards for common functions. So don’t worry too much about browser compatibility. Not every browser has its own BOM, and you don’t need to learn a set of BOM for each browser. It’s just that some browsers will have new functions that will be reflected in the BOM. .

DOM

1. DOM is the abbreviation of Document Object Model, which is the document object model.

2. DOM is a W3C standard.

3. The most fundamental object of DOM is document (actually window.document).

As can be seen from 1: DOM is related to documents. The documents here refer to web pages, which are HTML documents. The web page is sent by the server to the client browser. No matter what browser is used, the received HTML is the same, so the DOM has nothing to do with the browser. It focuses on the content of the web page itself. Since it has little to do with the browser, the standard can be easily determined.

Now that there are standards, everyone must abide by the standards. Browsers that do not abide by the standards will be spanked.

So what does JavaScript’s DOM do?

We know that HTML is composed of tags, tags within tags. JavaScript can get through the DOM what tags there are, what are the attributes in the tags, what is the content, etc...

As can be seen from the window.document in 3, the most fundamental object of the DOM is the window of the BOM A child object of the object.

The above picture illustrates the relationship between the two very well: the relationship between the two is that BOM contains DOM.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template