Represents an HTML or XML document.
Inherited Properties
| Property | Action | Mozilla | Safari | Chrome | Opera |
|---|---|---|---|---|---|
|
The absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI. This value is computed
as described in Base URIs. However, when the Document supports the feature "HTML" [DOM Level 2 HTML], the base URI is computed
using first the value of the href attribute of the HTML BASE element if any, and the value of the documentURI attribute from
the Document interface otherwise.
|
No Details | 1.8.1+ | 1.0+ | no | no |
|
|
|||||
|
This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no
effect. On setting, any possible children this node may have are removed and, if it the new string is not empty or null, replaced
by a single Text node containing the string this attribute is set to.
On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is
performed and the returned string does not contain the white spaces in element content (see the attribute Text.isElementContentWhitespace).
Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
The string returned is made of the text content of this node depending on its type, as defined below:
ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE
concatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE
nodes. This is the empty string if the node has no children.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE
nodeValue
DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE
null
|
No Details | 1.8.1+ | 1.0+ | no | no |
|
|
|||||
Properties
| Property | Action | Mozilla | Safari | Chrome | Opera |
|---|---|---|---|---|---|
|
The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument. No
lexical checking is performed when setting this attribute; this could result in a null value returned when using Node.baseURI.
Beware that when the Document supports the feature "HTML" [DOM Level 2 HTML], the href attribute of the HTML BASE element
takes precedence over this attribute when computing Node.baseURI.
|
No Details | 1.7+ | 1.0+ | no | no |
|
|
|||||
|
inputEncoding
: DOMString
An attribute specifying the encoding used for this document at the time of the parsing. This is null when it is not known,
such as when the Document was created in memory.
|
Show Details | 1.8.1+ | no | no | no |
|
|||||
|
xmlEncoding
: DOMString
An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified or when
it is not known, such as when the Document was created in memory.
|
Show Details | 1.8.1+ | no | no | no |
|
|||||
|
xmlStandalone
: boolean
An attribute specifying, as part of the XML declaration, whether this document is standalone. This is false when unspecified.
Note: No verification is done on the value when setting this attribute. Applications should use
Document.normalizeDocument()
with the "validate" parameter to verify if the value matches the validity constraint for standalone document declaration as
defined in [XML 1.0].
|
Show Details | 1.8.1+ | no | no | no |
|
|||||
|
xmlVersion
: DOMString
An attribute specifying, as part of the XML declaration, the version number of this document. If there is no declaration and
if this document supports the "XML" feature, the value is "1.0". If this document does not support the "XML" feature, the
value is always null. Changing this attribute will affect methods that check for invalid characters in XML names. Application
should invoke
Document.normalizeDocument() in order to check for invalid characters in the Nodes that are already
part of this Document.
|
Show Details | 1.8.1+ | no | no | no |
|
|||||
|
strictErrorChecking
: boolean
An attribute specifying whether error checking is enforced or not. When set to false, the implementation is free to not test
every possible error case normally defined on DOM operations, and not raise any DOMException on DOM operations or report errors
while using
Document.normalizeDocument(). In case of error, the behavior is undefined. This attribute is true
by default.
|
Show Details | 1.8.1+ | no | no | no |
|
|||||
|
domConfig
: DOMConfiguration
The configuration used when
Document.normalizeDocument() is invoked. |
Show Details | ||||
|
|||||
Inherited Functions
| Method | Action | Mozilla | Safari | Chrome | Opera | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
compareDocumentPosition(Node otherNode) : Number
Compares the reference node, i.e. the node on which this method is being called, with a node, i.e. the one passed as a parameter,
with regard to their position in the document and according to the document order.
|
Show Details | ||||||||||||
|
Parameters
Returns
|
|||||||||||||
|
getFeature(DOMString feature, DOMString version) : DOMObject
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified
in DOM Features. The specialized object may also be obtained by using binding-specific casting methods but is not necessarily
expected to, as discussed in Mixed DOM Implementations. This method also allows the implementation to provide specialized
objects which do not support the Node interface.
|
Show Details | ||||||||||||
|
Parameters
Returns
|
|||||||||||||
|
getUserData(DOMString key) : DOMUserData
Retrieves the object associated to a key on a this node. The object must first have been set to this node by calling
setUserData
with the same key.
|
Show Details | ||||||||||||
|
Parameters
Returns
|
|||||||||||||
|
insertBefore() : Node
|
Show Details | ||||||||||||
|
Returns
|
|||||||||||||
|
isDefaultNamespace(DOMString namespaceURI) : boolean
Checks whether the specified namespaceURI is the default namespace.
|
Show Details | ||||||||||||
|
Parameters
Returns
|
|||||||||||||
|
isEqualNode(Node otherNode) : boolean
Tests whether two nodes are equal.
This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which
can be tested with Node.isSameNode(). All nodes that are the same will also be equal, though the reverse may not be true.
Two nodes are equal if and only if the following conditions are satisfied:
* The two nodes are of the same type.
* The following string attributes are equal: nodeName, localName, namespaceURI, prefix, nodeValue. This is: they are both
null, or they have the same length and are character for character identical.
* The attributes NamedNodeMaps are equal. This is: they are both null, or they have the same length and for each node that
exists in one map there is a node that exists in the other map and is equal, although not necessarily at the same index.
* The childNodes NodeLists are equal. This is: they are both null, or they have the same length and contain equal nodes at
the same index. Note that normalization can affect equality; to avoid this, nodes should be normalized before being compared.
For two DocumentType nodes to be equal, the following conditions must also be satisfied:
* The following string attributes are equal: publicId, systemId, internalSubset.
* The entities NamedNodeMaps are equal.
* The notations NamedNodeMaps are equal.
On the other hand, the following do not affect equality: the ownerDocument, baseURI, and parentNode attributes, the specified
attribute for Attr nodes, the schemaTypeInfo attribute for Attr and Element nodes, the Text.isElementContentWhitespace attribute
for Text nodes, as well as any user data or event listeners registered on the nodes.
Note: As a general rule, anything not mentioned in the description above is not significant in consideration of equality checking.
Note that future versions of this specification may take into account more attributes and implementations conform to this
specification are expected to be updated accordingly.
|
Show Details | ||||||||||||
|
Parameters
Returns
|
|||||||||||||
|
isSameNode(Node otherNode) : boolean
Returns whether this node is the same node as the given one.
This method provides a way to determine whether two Node references returned by the implementation reference the same object.
When two Node references are references to the same object, even if through a proxy, the references may be used completely
interchangeably, such that all attributes have the same values and calling the same DOM method on either reference always
has exactly the same effect.
|
Show Details | ||||||||||||
|
Parameters
Returns
|
|||||||||||||
|
lookupNamespaceURI([DOMString prefix]) : DOMString
Look up the namespace URI associated to the given prefix, starting from this node.
|
Show Details | ||||||||||||
|
Parameters
Returns
|
|||||||||||||
|
lookupPrefix(DOMString namespaceURI) : DOMString
Look up the prefix associated to the given namespace URI, starting from this node. The default namespace declarations are
ignored by this method.
|
Show Details | ||||||||||||
|
Parameters
Returns
|
|||||||||||||
|
normalize() :
void
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form
where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates
Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view
of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer [XPointer] lookups)
that depend on a particular document tree structure are to be used. If the parameter "normalize-characters" of the DOMConfiguration
object attached to the Node.ownerDocument is true, this method will also fully normalize the characters of the Text nodes.
|
Show Details | ||||||||||||
|
|||||||||||||
|
setUserData(DOMString key, [DOMUserData userData]) : DOMString
Associate an object to a key on this node. The object can later be retrieved from this node by calling getUserData with the
same key.
|
Show Details | ||||||||||||
|
Parameters
Returns
|
|||||||||||||
Functions
| Method | Action | Mozilla | Safari | Chrome | Opera | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
adoptNode(Node externalNode) : Node
Adopts a node from an external document. The node and its subtree is removed from the document it's in (if any), and its
ownerDocument
is changed to the current document. The node can then be inserted into the current document.
|
Show Details | 1.8.1+ | 3.1+ | 5.0+ | 9.51+ | |||||||||||
|
Parameters
Returns
|
||||||||||||||||
|
normalizeDocument() :
void
This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form. As a
consequence, this method updates the replacement tree of EntityReference nodes and normalizes Text nodes, as defined in the
method
Node.normalize(). Otherwise, the actual result depends on the features being set on the Document.domConfig
object and governing what operations actually take place. Noticeably this method could also make the document namespace well-formed
according to the algorithm described in Namespace Normalization, check the character normalization, remove the CDATASection
nodes, etc.
|
Show Details | |||||||||||||||
|
||||||||||||||||
|
renameNode(Node node, DOMString namespaceURI, DOMString qualifiedName) : Node
Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE.
When possible this simply changes the name of the given node, otherwise this creates a new node with the specified name and
replaces the existing node with the new node as described below.
If simply changing the name of the given node is not possible, the following operations are performed: a new node is created,
any registered event listener is registered on the new node, any user data attached to the old node is removed from that node,
the old node is removed from its parent if it has one, the children are moved to the new node, if the renamed node is an Element
its attributes are moved to the new node, the new node is inserted at the position the old node used to have in its parent's
child nodes list if it has one, the user data that was attached to the old node is attached to the new node.
When the node being renamed is an Element only the specified attributes are moved, default attributes originated from the
DTD are updated according to the new element name. In addition, the implementation may update default attributes from other
schemas. Applications should use Document.normalizeDocument() to guarantee these attributes are up-to-date.
When the node being renamed is an Attr that is attached to an Element, the node is first removed from the Element attributes
map. Then, once renamed, either by modifying the existing node or creating a new one as described above, it is put back.
In addition,
* a user data event NODE_RENAMED is fired,
* when the implementation supports the feature "MutationNameEvents", each mutation operation involved in this method fires
the appropriate event, and in the end the event {http://www.w3.org/2001/xml-events, DOMElementNameChanged} or {http://www.w3.org/2001/xml-events,
DOMAttributeNameChanged} is fired.
|
Show Details | |||||||||||||||
|
Parameters
Returns
|
||||||||||||||||