The difference between BOM and DOM in JavaScript

BOM(Browser Object Model)

BOM is the browser object model. There is no relevant standard for BOM. The core object of BOM is the window object. The window object not only provides an API for javascript to access the browser, but also acts as a Global object in ECMAScript.

BOM is closely related to the browser. Many things in the browser can be controlled by javascript, such as opening windows, opening tabs, closing pages, favorites, etc. These functions have nothing to do with web content. Since there is no standard, different browsers can implement the same function in different ways. For example, add the function of favorites.

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

Although there is no unified standard, the js code of common functions of various browsers is similar, and there are default standards for common functions.

DOM(Document Object Model)

DOM is the document object model. DOM is the W3C standard. The most fundamental object of DOM is document (window.document). This object is actually an attribute of the window object. The uniqueness of this object is that this is the only one that belongs to both BOM and DOM object.

The DOM is related to the document, and the document here refers to the web page, that is, the html document. DOM has nothing to do with the browser. What he cares about is the content of the web page itself. Since it has nothing to do with the browser, the standard is set.

Leave a Reply