Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between the Browser Object Model and the Document Object Model?

Tags:

What is the difference between the two?

like image 810
yeeen Avatar asked Feb 06 '10 15:02

yeeen


People also ask

What is the main difference between BOM and the DOM?

Lesson Summary. The Document Object Model (DOM) defines a standard for accessing documents. The Browser Object Model (BOM) allows JavaScript to "talk to" the browser. In the HTML DOM, the Element object represents an HTML element, like P, DIV, A, TABLE, or any other HTML element.

What is DOM and BOM in angular?

The BOM (Browser Object Model) consists of the objects navigator , history , screen , location and document which are children of window . In the document node is the DOM (Document Object Model), the document object model, which represents the contents of the page.

What is the use of browser object model?

The browser object model (BOM) is a hierarchy of browser objects that are used to manipulate methods and properties associated with the Web browser itself. Objects that make up the BOM include the window object, navigator object, screen object, history, location object, and the document object.

What is meant by Document Object Model?

The Document Object Model (DOM) is a programming interface for web documents. It represents the page so that programs can change the document structure, style, and content. The DOM represents the document as nodes and objects; that way, programming languages can interact with the page.


2 Answers

The Browser Object Model is a larger representation of everything provided by the browser including the current document, location, history, frames, and any other functionality the browser may expose to JavaScript. The Browser Object Model is not standardized and can change based on different browsers.

The Document Object Model is standardized and is specific to current HTML document. It is exposed by the Browser Object Model (i.e., DOM is a subset of BOM).

like image 123
Samuel Neff Avatar answered Oct 18 '22 09:10

Samuel Neff


BOM

This is an informal term as there is no W3C or WHATWG standard that mentions it.

One simple definition would be that the BOM encompasses the entire object structure which is accessible via scripting in the browser, beginning with the window object which "contains everything else", since it's the global object.

The window object contains lots of properties (try console.dir( window );). These properties are specified in numerous web-standards. The "core" specification of the window object is as of now still specified in the HTML standard - see here, but I guess it's only a matter of time until the editors decide to transfer this specification into a separate standard. I'm definitively rooting for a "BOM" or "Browser Environment" standard to make things more logical and appropriate.

DOM

This on the other hand is a formal term. You can find definitions of this term in various standards, for instance the DOM4 standard states:

The DOM is a language- and platform neutral interface that allows programs and scripts to dynamically access and update the content and structure of documents.

Notice how the emphasis is on documents. Unlike the BOM which is basically and umbrella term for all the APIs in the browsers, DOM are only those APIs which deal with documents.

A simple definition would be that the DOM is implemented as the document object (which is the root of the DOM tree btw). Basically, the DOM tree (and everything inside it) can be considered part of the DOM. Analogously, everything beyond the DOM-tree is not part of the DOM.

beyond the DOM-tree == all the properties of window except the document object

like image 40
Šime Vidas Avatar answered Oct 18 '22 08:10

Šime Vidas