JavaScript - Tutorial - Objektreferenz - Der Document-Objekttyp

Die im Anhang A beschriebenen Eigenschaften des Objekts document bleiben in modernen Browsern weitgehend erhalten.


Der Document-Objekttyp ist vom Node-Objekttyp abgeleitet und ererbt dessen Attribute und Methoden.
Dieser Objekttyp findet seine Anwendung im document-Objekt.

Konstanten des Objekttyps Document
vom Node-Objekttyp ererbte Konstanten:
ELEMENT_NODE, ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, ENTITY_REFERENCE_NODE, ENTITY_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, DOCUMENT_FRAGMENT_NODE, NOTATION_NODE, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_PRECEDING, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_IS_CONTAINED, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC


Attribute des Objekttyps Document
vom Node-Objekttyp ererbte Attribute:
nodeName, nodeValue, nodeType, parentNode, childNodes, firstChild, lastChild, previousSibling, nextSibling, attributes, ownerDocument, namaspaceURI, prefix, localName, baseURI, textContent
Attribut Typ  Bedeutung
DOM-Attribute
actualEncoding  string  tatsächliche Codierungs-Information
config  object (DOMConfiguration), readonly  Konfigurations-Information
doctype  object (DocumentType), readonly  Information zum Typ des Dokuments
documentURI  string  Dokument-URI
documentElement  object (Element), readonly  Dokument Element
encoding  string  Codierungs-Information
implementation  object (DOMImplementation), readonly  DOMImplementation-Objekt
standalone  Boolean  einzeln stehend
strictErrorChecking  Boolean  strenge Fehlerkontrolle
version  string  Version
zusätzliche Kindknoten
anchors  object (NodeList), readonly  Elemente-Array zum <A name="...">-tag
applets  object (NodeList), readonly  Elemente-Array zum APPLET-tag
body  object (Element), readonly  Element zum BODY-tag
embeds  object (NodeList), readonly  Elemente-Array zum EMBED-tag
forms  object (NodeList), readonly  Elemente-Array zum FORM-tag
images  object (NodeList), readonly  Elemente-Array zum IMG-tag
links  object (NodeList), readonly  Elemente-Array zum <A href="...">-tag


Funktionen des Objekttyps Document
vom Node-Objekttyp ererbte Funktionen:
insertBefore, replaceChild, removeChild, appendChild, hasChildNodes, cloneNode, normalize, isSupported, hasAttributes, compareDocumentPosition, isSameNode, lookupPrefix, isDefaultNamespace, lookupNamespaceURI, isEqualNode, getFeature, setUserData, getUserData
Funktion  Bedeutung
DOM-Funktionen
adoptNode(source)  adoptiert einen Knoten aus einem anderen Dokument ohne ihn einzufügen
Attribute:
source (object (Node))
Rückgabewert:
adoptierter Knoten (object (Node))
createAttribute(name)  erzeugt ein neues Attribut, ohne es in das Dokument einzufügen
Attribute:
name (string)
Rückgabewert:
neu erzeugtes Attribut (object (Attr))
Um das Objekt einzubinden, muß es in ein dem jeweiligen Dokument untergeordnetes Element eingefügt werden, beispielsweise mittels setAttributeNode.
Mehr Information: Referenz Element-Objekt
createAttributeNS(namespaceURI,qualifiedName)  erzeugt ein neues Attribut, ohne es in das Dokument einzufügen
Attribute:
namespaceURI (string)
qualifiedName (string)
Rückgabewert:
neu erzeugtes Attribut (object (Attr))
createCDATASection(data)  erzeugt einen neuen CDATA-Knoten, ohne ihn in das Dokument einzufügen
Attribute:
data (string)
Rückgabewert:
neu erzeugter CDATA-Knoten (object (CDATASection, typgleich CharacterData))
createComment(data)  erzeugt einen neuen Kommentarknoten, ohne ihn in das Dokument einzufügen
Attribute:
data (string)
Rückgabewert:
neu erzeugter Kommentarknoten (object (Comment, typgleich CharacterData))
createDocumentFragment()  erzeugt ein neues Dokument-Fragment, ohne es in das Dokument einzufügen
Rückgabewert:
neu erzeugtes Element (object (DocumentFragment, typgleich Node))
createElement(tagName)  erzeugt ein neues Element, ohne es in das Dokument einzufügen
Attribute:
tagName (string), z.B. "DIV", "TABLE", "TD", ...
Rückgabewert:
neu erzeugtes Element (object (Element))
Um das Objekt einzubinden, muß es in ein dem jeweiligen Dokument untergeordnetes Element eingefügt werden, beispielsweise mittels appendChild, insertBefore oder replaceChild.
Mehr Information: Referenz Node-Objekt
createElementNS(namespaceURI,qualifiedName)  erzeugt ein neues Element, ohne es in das Dokument einzufügen
Attribute:
namespaceURI (string)
qualifiedName (string)
Rückgabewert:
neu erzeugtes Element (object (Element))
createEntityReference(name)  erzeugt einen neues EntityReference-Objekt, ohne es in das Dokument einzufügen
Attribute:
name (string)
Rückgabewert:
neu erzeugtes Objekt (object (EntityReference, typgleich Node))
createProcessingInstruction(target,data)  erzeugt einen neuen ProcessingInstruction-Knoten, ohne ihn in das Dokument einzufügen
Attribute:
target (string)
data (string)
Rückgabewert:
neu erzeugter ProcessingInstruction-Knoten (object (ProcessingInstruction))
createTextNode(data)  erzeugt einen neuen Textknoten, ohne ihn in das Dokument einzufügen
Attribute:
data (string)
Rückgabewert:
neu erzeugter Textknoten (object (Text))
getElementById(elementId)  gibt den untergeordneten Knoten mit der passenden ID zurück
Attribute:
elementId (string)
Rückgabewert:
Element (object (Element))
getElementsByTagName(tagname)  gibt ein Array aller untergeordneten Knoten mit eben jenem tag-Namen zurück
Attribute:
tagname (string)
Rückgabewert:
Array von Knoten (object (NodeList))
getElementsByTagNameNS(namespaceURI,qualifiedName)  gibt ein Array aller untergeordneten Knoten nach tag-Namen zurück
Attribute:
namespaceURI (string)
qualifiedName (string)
Rückgabewert:
Array von Knoten (object (NodeList))
importNode(importedNode,deep)  importiert einen Knoten aus einem anderen Dokument durch Kopieren, ohne ihn einzufügen
Attribute:
importedNode (object (Node))
deep (Boolean) wenn true, werden alle Unterobjekte mit importiert
Rückgabewert:
importierter Knoten (object (Node))
normalizeDocument()  "normalisiert" ein Dokument
renameNode(n,namespaceURI,qualifiedName)  benennt einen Knoten um
Attribute:
n (object (Node))
namespaceURI (string)
qualifiedName (string)
Rückgabewert:
umbenannter Knoten (object (Node))
zusätzliche Funktionen
getElementsByName(name)  gibt ein Array aller untergeordneten Knoten mit eben jenem Namen zurück
Attribute:
name (string)
Rückgabewert:
Array von Knoten (object (NodeList))
für weitere Information konsultiere man die Objektreferenz im Anhang A - das document-Objekt.


Autor: Ulrich Kritzner