I couldn't find any detailed reference but based on the comment in the MDC - HTMLImageElement
example, it seems that Image
is part of DOM level 0 whereas document.createElement
is part of DOM level 2.
DOM level 0 was invented by Netscape and provided a way to access the certain elements of the website. Basically all browsers support it for backwards compatibility.
But to be honest, I don't understand why the Image
constructor exists there, because, as far as I understood it, there was no way to manipulate the document with DOM level 0. Maybe it was only used internally by the browser to create the objects.
DOM level 2 is an official standard developed by the W3C.
For more information about the DOM levels, have a look at at quirksmode.org - Level 0 DOM and Wikipedia.
I've read somewhere that Image
, Form
, and Element
is called host objects, is this true?
Yes.
If it is, what are host objects?
The ECMAScript specification motivates host objects this way:
ECMAScript is an object-oriented programming language for performing computations and manipulating computational objects within a host environment. ECMAScript as defined here is not intended to be computationally self-sufficient; indeed, there are no provisions in this specification for input of external data or output of computed results. Instead, it is expected that the computational environment of an ECMAScript program will provide not only the objects and other facilities described in this specification but also certain environment-specific host objects, whose description and behaviour are beyond the scope of this specification except to indicate that they may provide certain properties that can be accessed and certain functions that can be called from an ECMAScript program.
and
host object
object supplied by the host environment to complete the execution environment of ECMAScript.
NOTE Any object that is not native is a host object.
So any object that is not defined in the specification and provided by the environment is a host object. These are for example in a browser (among others): window
, document
and console
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…