Home >Web Front-end >Front-end Q&A >Whether node contains dom and bom
Node does not contain dom and bom; bom refers to the browser object model, bom refers to the document object model, and node uses ecmascript for encoding, and there is no browser or document, and JavaScript runs behind The end environment platform, so the node does not contain dom and bom.
The operating environment of this article: Windows 10 system, nodejs version 16, Dell G3 computer.
Use ecmascript to encode in node
There is no bom and dom, which is different from js in the browser
First make two points clear:
1. BOM (Browser Object Model) refers to the browser object model, which can access and operate the browser window.
2. DOM (Document Object Model) Refers to the Document Object Model through which all elements of an HTML document can be accessed.
Please see, based on the above two points, you can answer your question.
There is no browser or documentation in node. Node is a back-end language, similar to PHP.
If you want to use BOM and DOM objects in NODE, you can try Electron.
Electron: uses JavaScript, HTML and CSS to build cross-platform desktop applications. (BOM and DOM can be used here)
Expand knowledge
1. DOM Document Object Model: It is a standard programming interface for processing extensible markup language recommended by the W3C organization.
DOM (Document Object Model) is the application programming interface (API) of HTML and XML.
An HTML document can be said to be a collection of nodes. DOM nodes include: element nodes, text nodes, and attribute nodes (i.e., element tags).
2. BOM Browser Object Model: A model used to describe the hierarchical relationship between objects. The browser object model provides an object structure that is independent of content and can interact with the browser window. .
The BOM mainly deals with browser windows and frames, but usually browser-specific JavaScript extensions are considered part of the BOM.
BOM contains DOM (object).
javacsript accesses, controls, and modifies the client (browser) by accessing the BOM (Browser Object Model) object.
3. Node attribute nodeName; node name nodeType; node type nodeValue; traverse the node tree childNodes;
Characteristics and methods of Node node
firstChild //Node,指向在childNodes列表中的第一个节点 lastChild //Node,指向在childNodes列表中的最后一个节点 parentNode //Node,指向父节 ownerDocument //Document,指向这个节点所属的文档 firstChild //Node,指向在childNodes列表中的第一个节点 lastChild //Node,指向在childNodes列表中的最后一个节点 parentNode //Node,指向父节点 childNodes //NodeList,所有子节点的列表 previousSibling /Node,/指向前一个兄弟节点:如果这个节点就是第一个节点,那么该值为null `nextSibling` //Node,指向后一个兄弟节点:如果这个节点就是最后一个节点,那么该值为null `hasChildNodes()` //Boolean,当childNodes包含一个或多个节点时,返回真值
3. DOM at the same time Two event models: bubbling events and capturing events
Bubble-type events: events are triggered in order from the most specific event target to the least specific event target
(Trigger The order is: div, body, html (IE 6.0 and Mozilla 1.0), document, window (Mozilla 1.0))
Capture-type events: The opposite process to bubbling events, events start from the least precise object Start triggering, and then go to the most accurate triggering sequence in the above example: document, div
Recommended learning: "nodejs video tutorial"
The above is the detailed content of Whether node contains dom and bom. For more information, please follow other related articles on the PHP Chinese website!