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

前端 未结 5 1883
旧巷少年郎
旧巷少年郎 2020-12-08 20:14

What is the difference between the two?

5条回答
  •  [愿得一人]
    2020-12-08 21:00

    "Browser Object Model" (BOM) is a term from the early 2000s that didn't catch on and was replaced[1] with the term "Web APIs"

    Web APIs are the JavaScript APIs available to web pages: any objects/interfaces, their properties, methods, and events the browser makes available to the page, except for the objects, like String, that are part of JavaScript language itself.

    The DOM (Document Object Model), in context of web development, is a subset of Web APIs concerned with manipulation of the structure and contents of web pages and other "documents".

    Historically, the DOM was designed as "a platform- and language-neutral interface" with DOM Level 1 specification describing both the ECMAScript (JavaScript) and Java bindings in appendices. You might still use DOM APIs to work with XML/HTML data from outside the browser (e.g. using Xerces in Java), but the "Living Standard" version of the DOM specification is maintained with the focus on the web use-case, and the most recent W3C implementation report includes mainly (if not only) web browsers.


    [1] See Google trends for "Browser object model", and how in a modern book (JavaScript Cookbook: Programming the Web) it's only briefly mentioned as 'BOM - see Web API'.

    [answer rewritten in 2019]

提交回复
热议问题