简体   繁体   中英

Where does HTML DOM start? window? document? document.defaultView?

As the title.

And is there a picture which introduces HTML DOM's construct?

The DOM ( Document Object Model) begins at the document node. It is referred to as the "root node".

Observe the following tree (corresponding nodeType s in parentheses):

[HTMLDocument](9)
    [DocumentType](10)
    [HTMLHTMLElement](1)
        [HTMLHeadElement](1)
            [HTMLTitleElement](1)
                [Text]Title(3)
        [HTMLBodyElement](1)

The tree¹ would be formed from the following markup:

<!DOCTYPE HTML><html><head><title>Title</title></head></body></html>

Note the distinct lack of whitespace. Adding whitespace would add text nodes to the document tree and clearly make it more difficult to simulate.

The window object is not part of the DOM. It is a host object implemented as the " global object " to complete an ECMAScript implementation. It has its own standard which is available from the W3C. Whereas the global object is required to complete an ECMAScript implementation, the DOM is not. This is exemplified in the node.js environment.

¹ Certain environments ignore the doctype node. I've observed Opera 5-9 and Safari 3.1 as environments that exhibit this behaviour.

There is no public standard for window, but most browsers support it with Window at the root. I've found a lot of good stuff at: http://www.w3schools.com (I have no connection with the site).

A simple google search for "dom html" images will get you images. Then...

When all else fails - go to the source: http://www.w3.org/TR/DOM-Level-2-HTML/html.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM