JavaScript 中的 DOM 和 BOM 是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4416317/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 12:19:38  来源:igfitidea点击:

What is the DOM and BOM in JavaScript?

javascriptdomdom-events

提问by Imran

What is the DOM and BOM in JavaScript? If someone could explain these in layman terms it would be great! I like to get a deeper understanding of these.

JavaScript 中的 DOM 和 BOM 是什么?如果有人能用外行的术语解释这些,那就太好了!我喜欢对这些有更深入的了解。

回答by thejh

The BOM (Browser Object Model) consists of the objects navigator, history, screen, locationand documentwhich are children of window. In the documentnode is the DOM (Document Object Model), the document object model, which represents the contents of the page. You can manipulate it using javascript.

该BOM(浏览器对象模型)是由对象navigatorhistoryscreenlocationdocument它们的孩子window。在document节点是DOM(文档对象模型),文档对象模型,它代表页的内容。您可以使用 javascript 操作它。

回答by decyclone

  • DOM - Document Object Model
  • BOM - Browser Object Model
  • DOM - 文档对象模型
  • BOM - 浏览器对象模型

This articleexplains relationship between Javascript, DOM and BOM.

这篇文章解释了 Javascript、DOM 和 BOM 之间的关系。

回答by Nick Craver

They're just different objects you're dealing with:

它们只是您正在处理的不同对象:

  • The DOM is the DocumentObject Model, which deals with the document, the HTML elements themselves, e.g. documentand all traversal you would do in it, events, etc.
  • The BOM is the BrowserObject Model, which deals with browser components aside from the document, like history, location, navigatorand screen(as well as some others that vary by browser).
  • DOM 是文档对象模型,它处理文档、HTML 元素本身,例如document以及您将在其中执行的所有遍历、事件等。
  • 的BOM是浏览器对象模型,它与从文档,如浏览器组件预留的交易historylocationnavigatorscreen(以及其他一些由浏览器而异)。

回答by Revathi Bala

DOM means Document Object model..when the webpage is loaded the browser creates a document object model for the page..All the objects are arranged as tree structure...

DOM 意思是文档对象模型..当网页加载时,浏览器为页面创建一个文档对象模型..所有对象都排列成树状结构......

BOM means Browser Object Model.window object is supported by all browsers it represents the window browser..All global JavaScript objects, functions, and variables automatically become members of the window object.

BOM 表示 Browser Object Model.window 对象被所有浏览器支持,它代表窗口浏览器。所有全局 JavaScript 对象、函数和变量自动成为 window 对象的成员。

回答by chaithanya

DOM : The document object represents the whole html document. When html document is loaded in the browser, it becomes a document object.

DOM :文档对象代表整个 html 文档。当 html 文档被加载到浏览器中时,它就变成了一个文档对象。

BOM : The window object represents a window in browser. An object of window is created automatically by the browser.

BOM : window 对象代表浏览器中的一个窗口。window 对象是由浏览器自动创建的。

回答by Julian

You can find more information about Javascript on Mozilla Foundation.

您可以在 Mozilla Foundation 上找到有关 Javascript 的更多信息。

DOM

DOM

https://developer.mozilla.org/en-US/docs/DOM/DOM_Reference/Introduction

https://developer.mozilla.org/en-US/docs/DOM/DOM_Reference/Introduction

BOM

物料清单

https://developer.mozilla.org/en-US/docs/WebAPI/Browser

https://developer.mozilla.org/en-US/docs/WebAPI/Browser

回答by Bamidele Alegbe

BOM means Browser Object Model . These are objects that you can use to manipulate the browser. they are navigator

BOM 表示浏览器对象模型。这些是您可以用来操作浏览器的对象。他们是导航员

  • navigator
  • screen
  • location
  • history
  • document
  • 航海家
  • 屏幕
  • 地点
  • 历史
  • 文档

they are all children of the Window Object. DOM is Document Object Model is part of the BOM and it helps you manipulate the content of the loaded page file. this include the HTML and CSS

它们都是 Window 对象的子对象。DOM 是文档对象模型,是 BOM 的一部分,它可以帮助您操作加载的页面文件的内容。这包括 HTML 和 CSS

回答by sai krishna

DOM -> Document Object Model in JavaScript is the API to access the elements inside the document. It maps the entire Document into an hierarchy of parent and child tree. Each node can hold number of children element or can inherit to other parent element in some or the other way.

JavaScript 中的 DOM -> 文档对象模型是访问文档内部元素的 API。它将整个 Document 映射到父子树的层次结构中。每个节点可以拥有多个子元素,也可以以某种方式继承其他父元素。

BOM -> 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.

BOM -> 浏览器对象模型是浏览器提供的所有内容的更大表示,包括当前文档、位置、历史记录、框架以及浏览器可能向 JavaScript 公开的任何其他功能。浏览器对象模型不是标准化的,可以根据不同的浏览器进行更改。