Package | dom.core |
Class | public class Document |
Inheritance | Document Node Object |
Implements | DocumentCSS, DocumentStyle, DocumentView, DocumentView, DocumentRange, DocumentEvent, DocumentTraversal, NodeSelector, DOMImplementationLS, DocumentLS |
Subclasses | HTMLDocument |
Introduced in: | DOM 0 |
Modified in: | DOM 3 Core |
In addition to the generalized DOM Core document interface, HTML documents also implement the DOM HTMLDocument interface, which is a more specialized interface for dealing with HTML documents (e.g., document.cookie, document.alinkColor). Methods listed here that are part of this more specialized interface have an asterisk (*) next to them.
The document is contained by the window object and may contain any number of elements.
The document interface provides access to things such as the document type, its color and formatting, plugins and applets, as well providing methods for creating and manipulating all of the document's child nodes, or elements, such as BODY and TABLE elements.
See also
Property | Defined By | ||
---|---|---|---|
DOM 3 Load and Save Obsolete async : Boolean
Indicates whether the method load should be synchronous or asynchronous. | Document | ||
DOM 1 Core attributes : NamedNodeMap [read-only]
Returns an unordered collection of Attr nodes. | Node | ||
Non-Standard baseName : DOMString [read-only]
Returns the base name for the name qualified with the namespace. | Node | ||
DOM 3 Core baseURI : DOMString [read-only]
The absolute base URI of this node or null if the implementation
wasn't able to obtain an absolute URI. | Node | ||
DOM 1 Core childNodes : NodeList [read-only]
Returns an ordered collection of node objects that are children of
the current element. | Node | ||
Non-Standard dataType : *
Specifies the data type for this node. | Node | ||
DOM 2 Views defaultView : AbstractView [read-only]
The default AbstractView for this Document, or null if none available. | Document | ||
Non-Standard definition : Node [read-only]
Returns the definition of the node in the document type definition (DTD) or schema. | Node | ||
DOM 1 Core doctype : DocumentType [read-only]
The Document Type Declaration (see DocumentType) associated with this
document. | Document | ||
DOM 1 Core documentElement : Element [read-only]
This is a convenience attribute that allows direct access to the child node
that is the document element of the document. | Document | ||
DOM 3 Core documentURI : DOMString
The location of the document or null if undefined or if the Document was
created using DOMImplementation.createDocument. | Document | ||
DOM 3 Core domConfig : DOMConfiguration [read-only]
The configuration used when Document.normalizeDocument() is invoked. | Document | ||
DOM 1 Core firstChild : Node [read-only]
Returns the node's first child in the tree, or null if the node is
childless. | Node | ||
DOM 1 Core implementation : DOMImplementation [read-only]
The DOMImplementation object that handles this document. | Document | ||
DOM 3 Core inputEncoding : DOMString [read-only]
Returns a string representing the encoding under which the document was parsed (e.g. | Document | ||
DOM 1 Core lastChild : Node [read-only]
Returns the last child of a node. | Node | ||
CSSOM lastStyleSheetSet : DOMString [read-only]
This attribute must initially have the value null. | Document | ||
DOM 2 Core localName : DOMString [read-only]
Returns the local part of the qualified name of this node. | Node | ||
DOM 2 Core namespaceURI : DOMString [read-only]
The namespace URI of the node, or null if it is unspecified (read-only). | Node | ||
DOM 1 Core nextSibling : Node [read-only]
Returns the node immediately following the specified one in its
parent's childNodes list, or null if the specified node is the
last node in that list. | Node | ||
DOM 1 Core nodeName : DOMString [read-only]
Returns the name of the current node as a string. | Node | ||
Non-Standard nodePrincipal : nsIPrincipal [read-only]
Returns the nsIPrincipal object representing current security
context of the node. | Node | ||
DOM 1 Core nodeType : Number [read-only]
Returns an integer code representing the type of the node. | Node | ||
Non-Standard nodeTypedValue : *
Contains the node value expressed in its defined data type. | Node | ||
Non-Standard nodeTypeString : DOMString [read-only]
Returns the node type in string form. | Node | ||
DOM 1 Core nodeValue : DOMString
Returns or sets the value of the current node. | Node | ||
DOM 1 Core ownerDocument : Document [read-only]
The Document object associated with this node. | Node | ||
DOM 1 Core parentNode : Node [read-only]
Returns the parent of the specified node in the DOM tree. | Node | ||
Non-Standard parsed : Boolean [read-only]
Indicates the parsed status of the node and child nodes. | Node | ||
CSSOM preferredStyleSheetSet : DOMString [read-only]
This attribute must be the preferred style sheet set as set by the author. | Document | ||
DOM 2 Core prefix : DOMString
Returns the namespace prefix of the specified node, or null if no
prefix is specified. | Node | ||
DOM 1 Core previousSibling : Node [read-only]
Returns the node immediately preceding the specified one in its
parent's childNodes list, null if the specified node is the first
in that list. | Node | ||
CSSOM selectedStyleSheetSet : DOMString
This attribute indicates which style sheet set is in use. | Document | ||
Non-Standard specified : Boolean [read-only]
Indicates whether the node (usually an attribute) is explicitly specified or derived
from a default value in the document type definition (DTD) or schema. | Node | ||
DOM 3 Core strictErrorChecking : Boolean
An attribute specifying whether error checking is enforced or not. | Document | ||
DOM 2 Style styleSheets : StyleSheetList [read-only]
A list containing all the style sheets explicitly linked into or embedded in a document. | Document | ||
CSSOM styleSheetSets : DOMStringList [read-only]
This must be a live list of the currently available style sheet sets. | Document | ||
Non-Standard text : DOMString
Represents the text content of the node or the concatenated text representing the node and its descendants. | Node | ||
DOM 3 Core textContent : DOMString
Gets or sets the text content of a node and its descendants. | Node | ||
Non-Standard xml : DOMString [read-only]
Contains the XML representation of the node and all its descendants. | Node | ||
DOM 3 Core xmlEncoding : DOMString [read-only]
An attribute specifying, as part of the XML declaration, the encoding of
this document. | Document | ||
DOM 3 Core xmlStandalone : Boolean
An attribute specifying, as part of the XML declaration, whether this
document is standalone. | Document | ||
DOM 3 Core xmlVersion : DOMString
An attribute specifying, as part of the XML declaration, the version
number of this document. | Document |
Method | Defined By | ||
---|---|---|---|
If the document is currently being loaded as a result of the method load being invoked the loading and parsing is immediately
aborted. | Document | ||
Associates a function with a particular event and binds the event to the current node. | Node | ||
DOM 3 Events addEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void
Registers an event listener, depending on the useCapture parameter, on the
capture phase of the DOM event flow or its target and bubbling phases. | Node | ||
Attempts to adopt a node from another document to this document. | Document | ||
Adds a node to the end of the list of children of a specified parent node. | Node | ||
Binds the specified function to an event, so that the function gets called whenever
the event fires on the object. | Document | ||
Tests if the implementation can generate events of a specified type. | Document | ||
Returns a duplicate of the current node. | Node | ||
Compares the position of the current node against another node in any other document. | Node | ||
Creates an Attr of the given name. | Document | ||
Creates an attribute of the given qualified name and namespace URI. | Document | ||
Creates a CDATASection node whose value is the specified string. | Document | ||
Creates a Comment node given the specified string. | Document | ||
Creates an empty DocumentFragment object. | Document | ||
Creates an element of the type specified. | Document | ||
Creates an element of the given qualified name and namespace URI. | Document | ||
Creates an EntityReference object. | Document | ||
Creates an event object of the type specified. | Document | ||
Generates an event object to pass event context information when you use the fireEvent method. | Document | ||
Create a new empty input source object where LSInput.characterStream, LSInput.byteStream, LSInput.stringData
LSInput.systemId, LSInput.publicId, LSInput.baseURI, and LSInput.encoding are null, and LSInput.certifiedText is false. | Document | ||
Create a new empty output destination object where LSOutput.characterStream, LSOutput.byteStream, LSOutput.systemId,
LSOutput.encoding are null. | Document | ||
Create a new LSParser. | Document | ||
Create a new LSSerializer object. | Document | ||
DOM 2 TR createNodeIterator(root:Node, whatToShow:Number, filter:NodeFilter, entityReferenceExpansion:Boolean):NodeIterator
Create a new NodeIterator over the subtree rooted at the specified node. | Document | ||
Creates a ProcessingInstruction node given the specified name and
data strings. | Document | ||
This interface can be obtained from the object implementing the Document interface using binding-specific
casting methods. | Document | ||
Creates a style sheet for the document. | Document | ||
Creates a Text node given the specified string. | Document | ||
DOM 2 TR createTreeWalker(root:Node, whatToShow:Number, filter:NodeFilter, entityReferenceExpansion:Boolean):TreeWalker
Create a new TreeWalker over the subtree rooted at the specified node. | Document | ||
Unbinds the specified function from the event, so that the function stops receiving notifications when the event fires. | Document | ||
Dispatches an event to fire on a node artificially. | Node | ||
Returns the element from the document whose elementFromPoint method is being called which is the
topmost element which lies under the given point. | Document | ||
Invoking this method must change the disabled attribute on each StyleSheet object with a title in the
styleSheets attribute, so that all those whose title matches the name argument are enabled, and all others
are disabled. | Document | ||
Returns a NodeList of all the Elements in document order with a
given tag name and are contained in the document. | Document | ||
Returns a NodeList of all the Elements with a given local name and
namespace URI in document order. | Document | ||
Returns the Element that has an ID attribute with the given value. | Document | ||
This method returns a specialized object which implements the
specialized APIs of the specified feature and version, as specified
in DOM Features. | Node | ||
This method is used to retrieve the override style declaration for a specified element and a specified pseudo-element. | Document | ||
Retrieves the object associated to a key on a this node. | Node | ||
DOM 2 Core hasAttributes():Boolean
Returns a boolean value of true or false, indicating if the current element
has any attributes or not. | Node | ||
DOM 1 Core hasChildNodes():Boolean
Returns a value that indicates whether the object has children. | Node | ||
Imports a node from another document to this document, without altering or removing the source
node from the original document; this method creates a new copy of the source node. | Document | ||
Inserts the specified node before a reference element as a child of
the current node. | Node | ||
Returns true if the namespace is the default namespace on the given
node or false if not. | Node | ||
Tests whether two nodes are equal. | Node | ||
Returns whether this node is the same node as the given one. | Node | ||
Tests whether the DOM implementation implements a specific feature
and that feature is supported by this node. | Node | ||
Replaces the content of the document with the result of parsing the given URI. | Document | ||
Replace the content of the document with the result of parsing the input string, this method is always synchronous. | Document | ||
Takes a prefix and returns the namespaceURI associated with it on the
given node if found (and null if not). | Node | ||
Returns the prefix for a given namespaceURI if present, and null if not. | Node | ||
DOM 1 Core normalize():void
Puts the specified node and all of its subtree into a "normalized"
form. | Node | ||
DOM 3 Core normalizeDocument():void
This method acts as if the document was going through a save and load
cycle, putting the document in a "normal" form. | Document | ||
Returns the first element that is a descendent of the element on which it is invoked that matches the specified group of selectors. | Document | ||
Returns a list of all elements descended from the element on which it is invoked that match the specified group of selectors. | Document | ||
Removes a child node from the object. | Node | ||
Removes an event listener. | Node | ||
DOM 3 Events removeEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void
Removes an event listener. | Node | ||
Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE. | Document | ||
Replaces an existing child element with a new child element. | Node | ||
Save the document or the given node to a string (i.e. | Document | ||
Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as IXMLDOMNodeList. | Node | ||
Applies the specified pattern-matching operation to this node's context and returns the first matching node. | Node | ||
Associate an object to a key on this node. | Node | ||
Processes this node and its children using the supplied Extensible Stylesheet Language Transformations
(XSLT) style sheet and returns the resulting transformation. | Node | ||
Processes this node and its children using the supplied Extensible Stylesheet Language Transformations (XSLT) style sheet
and returns the resulting transformation. | Node | ||
Non-Standard updateSettings():void
Allows updating the print settings for the page. | Document |
Event | Summary | Defined By | ||
---|---|---|---|---|
This is a general event for notification of all changes to the document. | Document | |||
The DOM Implementation finishes loading the resource (such as the document) and any dependent resources (such as images, style sheets, or scripts). | Document | |||
A mouse wheel has been rotated. | Document | |||
A mouse wheel has been rotated around the y-axis. | Document | |||
Is fired when the browser switches between online and offline mode. | Document | |||
Is fired when the browser switches between online and offline mode. | Document | |||
A document view or an element has been resized. | Document | |||
A document view or an element has been scrolled. | Document | |||
The DOM implementation removes from the environment the resource (such as the document) or any dependent resources (such as images, style sheets, scripts). | Document |
DOM 3 Load and Save Obsolete async | property |
async:Boolean
Obsolete
Indicates whether the method load should be synchronous or asynchronous. When the async attribute is set to true the load method returns control to the caller before the document has completed loading.
public function get async():Boolean
public function set async(value:Boolean):void
See also
function loadXMLData(e) { alert(new XMLSerializer().serializeToString(e.target)); // Gives querydata.xml contents as string } var xmlDoc = document.implementation.createDocument("", "test", null); xmlDoc.async = false; xmlDoc.onload = loadXMLData; xmlDoc.load('querydata.xml');
DOM 2 Views defaultView | property |
defaultView:AbstractView
[read-only] Introduced in: | DOM 2 Core |
The default AbstractView for this Document, or null if none available.
Note: document.defaultView is generally a reference to the window object for the document, however that is not defined in the specification and can't be relied upon for all host environments, particularly as not all browsers implement it.
public function get defaultView():AbstractView
See also
DOM 1 Core doctype | property |
doctype:DocumentType
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 1 Core |
Modified in: | DOM 3 Core |
The Document Type Declaration (see DocumentType) associated with this document. For XML documents without a document type declaration this returns null. For HTML documents, a DocumentType object may be returned, independently of the presence or absence of document type declaration in the HTML document.
This provides direct access to the DocumentType node, child node of this Document. This node can be set at document creation time and later changed through the use of child nodes manipulation methods, such as Node.insertBefore, or Node.replaceChild. Note, however, that while some implementations may instantiate different types of Document objects supporting additional features than the "Core", such as "HTML", based on the DocumentType specified at creation time, changing it afterwards is very unlikely to result in a change of the features supported.
public function get doctype():DocumentType
See also
DOM 1 Core documentElement | property |
documentElement:Element
[read-only] Introduced in: | DOM 1 Core |
This is a convenience attribute that allows direct access to the child node that is the document element of the document.
Note: HTML documents typically contain a single child node, <html>, perhaps with a DOCTYPE declaration before it. XML documents often contain multiple child nodes: the root element, the DOCTYPE declaration, and processing instructions.
That's why you should use document.documentElement rather than document.firstChild to get the root element.
public function get documentElement():Element
See also
var rootElement = document.documentElement; var firstTier = rootElement.childNodes; // firstTier is the NodeList of the direct children of the root element for (var i = 0; i < firstTier.length; i++) { // do something with each direct kid of the root element // as firstTier[i] }
DOM 3 Core documentURI | property |
documentURI:DOMString
Introduced in: | DOM 3 Core |
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", the href attribute of the HTML BASE element takes precedence over this attribute when computing Node.baseURI.
public function get documentURI():DOMString
public function set documentURI(value:DOMString):void
See also
DOM 3 Core domConfig | property |
domConfig:DOMConfiguration
[read-only] Introduced in: | DOM 3 Core |
The configuration used when Document.normalizeDocument() is invoked.
Note (Mozilla): This is not implemented in Mozilla at present.
public function get domConfig():DOMConfiguration
See also
DOM 1 Core implementation | property |
implementation:DOMImplementation
[read-only] Introduced in: | DOM 1 Core |
The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.
public function get implementation():DOMImplementation
See also
var modName = "HTML"; var modVer = "2.0"; var conformTest = document.implementation.hasFeature(modName, modVer); alert("DOM " + modName + " " + modVer + " supported?: " + conformTest); // alerts with: "DOM HTML 2.0 supported?: true" if DOM Level 2 HTML module is supported.
A list of module names (e.g., Core, HTML, XML, etc) is available in the DOM Level 2 Conformance Section
DOM 3 Core inputEncoding | property |
inputEncoding:DOMString
[read-only] Introduced in: | DOM 3 Core |
Returns a string representing the encoding under which the document was parsed (e.g. ISO-8859-1). This is null when it is not known, such as when the Document was created in memory.
public function get inputEncoding():DOMString
See also
CSSOM lastStyleSheetSet | property |
lastStyleSheetSet:DOMString
[read-only] Introduced in: | CSSOM |
This attribute must initially have the value null. Its value changes when the selectedStyleSheetSet attribute is set.
public function get lastStyleSheetSet():DOMString
See also
CSSOM preferredStyleSheetSet | property |
preferredStyleSheetSet:DOMString
[read-only] Introduced in: | CSSOM |
This attribute must be the preferred style sheet set as set by the author. It is determined from the order of style sheet declarations and the Default-Style HTTP headers. If there is no preferred style sheet set, this attribute must be the empty string. The case of this attribute must exactly match the case given by the author where the preferred style sheet is specified or implied. This attribute must never be null.
public function get preferredStyleSheetSet():DOMString
See also
CSSOM selectedStyleSheetSet | property |
selectedStyleSheetSet:DOMString
Introduced in: | CSSOM |
This attribute indicates which style sheet set is in use. This attribute is live; changing the disabled attribute on style sheets directly will change the value of this attribute.
If all the sheets that are enabled and have a title have the same title (by case-sensitive comparisons) then the value of this attribute must be exactly equal to the title of the first enabled style sheet with a title in the styleSheets list. Otherwise, if style sheets from different sets are enabled, then the return value must be null (there is no way to determine what the currently selected style sheet set is in those conditions). Otherwise, either all style sheets that have a title are disabled, or there are no alternative style sheets, and selectedStyleSheetSet must return the empty string.
public function get selectedStyleSheetSet():DOMString
public function set selectedStyleSheetSet(value:DOMString):void
See also
DOM 3 Core strictErrorChecking | property |
strictErrorChecking:Boolean
Introduced in: | DOM 3 Core |
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.
The default value is true
.
public function get strictErrorChecking():Boolean
public function set strictErrorChecking(value:Boolean):void
See also
DOM 2 Style styleSheets | property |
styleSheets:StyleSheetList
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 2 Core |
A list containing all the style sheets explicitly linked into or embedded in a document. For HTML documents, this includes external style sheets, included via the HTML LINK element, and inline STYLE elements. In XML, this includes external style sheets, included via style sheet processing instructions.
public function get styleSheets():StyleSheetList
See also
CSSOM styleSheetSets | property |
styleSheetSets:DOMStringList
[read-only] Introduced in: | CSSOM |
This must be a live list of the currently available style sheet sets. This list is constructed by enumerating all the style sheets for this document available to the implementation, in the order they are listed in the styleSheets attribute, adding the title of each style sheet with a title to the list, avoiding duplicates by dropping titles that match (case-sensitively) titles that have already been added to the list.
public function get styleSheetSets():DOMStringList
See also
DOM 3 Core xmlEncoding | property |
xmlEncoding:DOMString
[read-only] Introduced in: | DOM 3 Core |
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.
If the XML Declaration states:
<?xml version="1.0" encoding="UTF-16"?>
...the result should be "UTF-16".
Note (Mozilla): However, Firefox 3.0 includes information on endianness (e.g., UTF-16BE for big endian encoding), and while this extra information is removed as of Firefox 3.1b3, Firefox 3.1b3 is still consulting the file's encoding, rather than the XML Declaration as the spec defines it ("An attribute specifying, as part of the XML declaration, the encoding of this document.").
public function get xmlEncoding():DOMString
See also
DOM 3 Core xmlStandalone | property |
xmlStandalone:Boolean
Introduced in: | DOM 3 Core |
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.
public function get xmlStandalone():Boolean
public function set xmlStandalone(value:Boolean):void
DOMException — NOT_SUPPORTED_ERR: Raised if this document
does not support the "XML" feature.
|
See also
DOM 3 Core xmlVersion | property |
xmlVersion:DOMString
Introduced in: | DOM 3 Core |
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.
DOM applications may use the DOMImplementation.hasFeature(feature, version) method with parameter values "XMLVersion" and "1.0" (respectively) to determine if an implementation supports XML 1.0. DOM applications may use the same method with parameter values "XMLVersion" and "1.1" (respectively) to determine if an implementation supports XML 1.1. In both cases, in order to support XML, an implementation must also support the "XML" feature defined in this specification. Document objects supporting a version of the "XMLVersion" feature must not raise a NOT_SUPPORTED_ERR exception for the same version number when using Document.xmlVersion.
public function get xmlVersion():DOMString
public function set xmlVersion(value:DOMString):void
DOMException — NOT_SUPPORTED_ERR: Raised if the version is set
to a value that is not supported by this Document or if this document does
not support the "XML" feature.
|
See also
DOM 3 Load and Save Obsolete abort | () | method |
public function abort():void
Obsolete
If the document is currently being loaded as a result of the method load being invoked the loading and parsing is immediately aborted. The possibly partial result of parsing the document is discarded and the document is cleared.
See also
DOM 3 Core adoptNode | () | method |
public function adoptNode(source:Node):Node
Introduced in: | DOM 3 Core |
Attempts to adopt a node from another document to this document. If supported, it changes the ownerDocument of the source node, its children, as well as the attached attribute nodes if there are any. If the source node has a parent it is first removed from the child list of its parent. This effectively allows moving a subtree from one document to another (unlike importNode() which create a copy of the source node instead of moving it). When it fails, applications should use Document.importNode() instead. Note that if the adopted node is already part of this document (i.e. the source and target document are the same), this method still has the effect of removing the source node from the child list of its parent, if any. The following list describes the specifics for each type of node.
Attribute | Value |
---|---|
ATTRIBUTE_NODE | The ownerElement attribute is set to null and the specified flag is set to true on the adopted Attr. The descendants of the source Attr are recursively adopted. |
DOCUMENT_FRAGMENT_NODE | The descendants of the source node are recursively adopted. |
DOCUMENT_NODE | Document nodes cannot be adopted. |
DOCUMENT_TYPE_NODE | DocumentType nodes cannot be adopted. |
ELEMENT_NODE | Specified attribute nodes of the source element are adopted. Default attributes are discarded, though if the document being adopted into defines default attributes for this element name, those are assigned. The descendants of the source element are recursively adopted. |
ENTITY_NODE | Entity nodes cannot be adopted. |
ENTITY_REFERENCE_NODE | Only the EntityReference node itself is adopted, the descendants are discarded, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned. |
NOTATION_NODE | Notation nodes cannot be adopted. |
PROCESSING_INSTRUCTION_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE | These nodes can all be adopted. No specifics. |
Note: Since it does not create new nodes unlike the Document.importNode() method, this method does not raise an INVALID_CHARACTER_ERR exception, and applications should use the Document.normalizeDocument() method to check if an imported name is not an XML name according to the XML version in use.
Parameters
source:Node — The node to move into this document.
|
Node — The adopted node, or null if this operation fails, such as when
the source node comes from a different implementation.
|
DOMException — NOT_SUPPORTED_ERR: Raised if the source
node is of type DOCUMENT, DOCUMENT_TYPE.
| |
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised when
the source node is readonly.
|
See also
attachEvent | () | method |
public function attachEvent(type:DOMString, listener:Function):Boolean
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Non-standard (Microsoft)
Binds the specified function to an event, so that the function gets called whenever the event fires on the object.
Parameters
type:DOMString — The event string should include the "on" prefix (ie: "onload", "onclick" etc).
| |
listener:Function — The function or method to associate with the event.
|
Boolean — true (successful) or false (failed).
|
See also
if (window.attachEvent) window.attachEvent("onload", statusreport); //invoke function
DOM 3 Events canDispatch | () | method |
public function canDispatch(namespaceURI:DOMString, type:DOMString):Boolean
Introduced in: | DOM 3 Events |
Tests if the implementation can generate events of a specified type.
Parameters
namespaceURI:DOMString — Specifies the Event.namespaceURI of the event.
| |
type:DOMString — Specifies the Event.type of the event.
|
Boolean — If the implementation can generate and dispatch this event type
|
See also
DOM 1 Core createAttribute | () | method |
public function createAttribute(name:DOMString):Attr
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 1 Core |
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method. To create an attribute with a qualified name and namespace URI, use the createAttributeNS method.
Parameters
name:DOMString — The name of the attribute.
|
Attr — A new Attr object with the nodeName attribute set to name,
and localName, prefix, and namespaceURI set to null. The value of
the attribute is the empty string.
|
DOMException — INVALID_CHARACTER_ERR: Raised if the
specified name is not an XML name according to the XML version
in use specified in the Document.xmlVersion attribute.
|
See also
<html> <head> <title> create/set/get Attribute example</title> <script type="text/javascript"> function doAttrib() { var node = document.getElementById("div1"); var a = document.createAttribute("my_attrib"); a.nodeValue = "newVal"; node.setAttributeNode(a); alert(node.getAttribute("my_attrib")); // "newVal" } // alternative form not actually using createAttribute //function doAttrib() { //var node = document.getElementById("div1"); //node.setAttribute("my_attrib", "newVal"); //alert(node.getAttribute("my_attrib")); // "newVal" //} </script> </head> <body onload="doAttrib();"> <div id="div1"> <p>Some content here</p> </div> </body> </html>
DOM 2 Core createAttributeNS | () | method |
public function createAttributeNS(namespaceURI:DOMString, qualifiedName:DOMString):Attr
Introduced in: | DOM 2 Core |
Creates an attribute of the given qualified name and namespace URI. Per XML Namespaces, applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.
Parameters
namespaceURI:DOMString — The namespace URI of the attribute to create.
| |
qualifiedName:DOMString — The qualified name of the attribute to instantiate.
|
Attr — A new Attr object with the following attributes:
|
DOMException — INVALID_CHARACTER_ERR: Raised if the
specified qualifiedName is not an XML name according to the XML
version in use specified in the Document.xmlVersion attribute.
| |
DOMException — NAMESPACE_ERR: Raised if the qualifiedName
is a malformed qualified name, if the qualifiedName has a prefix and
the namespaceURI is null, if the qualifiedName has a prefix that is
"xml" and the namespaceURI is different from
"http://www.w3.org/XML/1998/namespace", if the qualifiedName or its
prefix is "xmlns" and the namespaceURI is different from
"http://www.w3.org/2000/xmlns/", or if the namespaceURI is
"http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its
prefix is "xmlns".
| |
DOMException — NOT_SUPPORTED_ERR: Always thrown if the
current document does not support the "XML" feature, since namespaces
were defined by XML.
|
See also
DOM 1 Core createCDATASection | () | method |
public function createCDATASection(data:DOMString):CDATASection
Introduced in: | DOM 1 Core |
Creates a CDATASection node whose value is the specified string.
Note (Mozilla): Will throw a NS_ERROR_DOM_INVALID_CHARACTER_ERR exception if one tries to submit the closing CDATA sequence ("]]>") as part of the data, so unescaped user-provided data cannot be safely used without with this method getting this exception (createTextNode() can often be used in its place).
Parameters
data:DOMString — The data for the CDATASection contents.
|
CDATASection — The new CDATASection object.
|
DOMException — NOT_SUPPORTED_ERR: Raised if this
document is an HTML document.
|
See also
var docu = new DOMParser().parseFromString('<xml></xml>', "application/xml"); var cdata = docu.createCDATASection('Some <CDATA> data & then some'); docu.getElementsByTagName('xml')[0].appendChild(cdata); alert(new XMLSerializer().serializeToString(docu)); // Displays: <xml><![CDATA[Some <CDATA> data & then some]]></xml>
DOM 1 Core createComment | () | method |
public function createComment(data:DOMString):Comment
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 1 Core |
Creates a Comment node given the specified string.
Note (Mozilla): Will throw a NS_ERROR_DOM_INVALID_CHARACTER_ERR exception if one tries to include the "--" sequence as part of the data, so if based on user data, this potential string would need to be escaped or have its exception caught.
Parameters
data:DOMString — The data for the node.
|
Comment — The new Comment object.
|
See also
var docu = new DOMParser().parseFromString('<xml></xml>', "application/xml"); var comment = docu.createComment('This is a not-so-secret comment in your document'); docu.getElementsByTagName('xml')[0].appendChild(comment); alert(new XMLSerializer().serializeToString(docu)); // Displays: <xml><!--This is a not-so-secret comment in your document--></xml>
DOM 1 Core createDocumentFragment | () | method |
public function createDocumentFragment():DocumentFragment
Introduced in: | DOM 1 Core |
Creates an empty DocumentFragment object.
ReturnsDocumentFragment — A new DocumentFragment.
|
See also
var frag = document.createDocumentFragment(); frag.appendChild(document.createTextNode('Ipsum Lorem')); document.body.appendChild(frag);
DOM 1 Core createElement | () | method |
public function createElement(tagName:DOMString):Element
Introduced in: | DOM 1 Core |
Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object. In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element. To create an element with a qualified name and namespace URI, use the createElementNS method.
Note (Mozilla): Gecko implementation of createElement doesn't conform to the DOM spec for XUL and XHTML documents: localName and namespaceURI are not set to null on the created element. See bug 280692 for details.
Note (IE): In Microsoft Internet Explorer 4.0, the only new elements you can create are img, area, and option. As of Internet Explorer 5, you can create all elements programmatically, except frame and iframe. The properties of these created elements are read/write and can be accessed programmatically. Before you use new objects, you must explicitly add them to their respective collections or to the document. To insert new elements into the current document, use the insertBefore method or the appendChild method.
Note (IE): You must perform a second step when you use createElement to create the input element. The createElement method generates an input text box, because that is the default input type property. To insert any other kind of input element, first invoke createElement for input, and then set the type property to the appropriate value in the next line of code.
Note (IE): Attributes can be included with the tagName as long as the entire string is valid HTML. To include the NAME attribute at run time on objects created with the createElement method, use the tagName.
Note (IE): Use the tagName to include attributes when form elements are created that will be reset using the reset method or a BUTTON with a TYPE attribute value of reset.
Parameters
tagName:DOMString — The name of the element type to instantiate. For XML,
this is case-sensitive, otherwise it depends on the case-sensitivity
of the markup language in use. In that case, the name is mapped to
the canonical form of that markup by the DOM implementation.
|
Element — A new Element object with the nodeName attribute set to tagName,
and localName, prefix, and namespaceURI set to null.
|
DOMException — INVALID_CHARACTER_ERR: Raised if the
specified name is not an XML name according to the XML version in
use specified in the Document.xmlVersion attribute.
|
See also
<html> <head> <title>||Working with elements||</title> </head> <script type="text/javascript"> var my_div = null; var newDiv = null; function addElement() { // create a new div element // and give it some content newDiv = document.createElement("div"); newDiv.innerHTML = "<h1>Hi there and greetings!</h1>"; // add the newly created element and it's content into the DOM my_div = document.getElementById("org_div1"); document.body.insertBefore(newDiv, my_div); } </script> <body onload="addElement()"> <div id='org_div1'> The text above has been created dynamically.</div> </body> </html>
DOM 2 Core createElementNS | () | method |
public function createElementNS(namespaceURI:DOMString, qualifiedName:DOMString):Element
Introduced in: | DOM 2 Core |
Creates an element of the given qualified name and namespace URI. Per XML Namespaces, applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.
Parameters
namespaceURI:DOMString — The namespace URI of the element to create.
| |
qualifiedName:DOMString — The qualified name of the element type to instantiate.
|
Element — A new Element object with the following attributes:
|
DOMException — INVALID_CHARACTER_ERR: Raised if the
specified qualifiedName is not an XML name according to the XML
version in use specified in the Document.xmlVersion attribute.
| |
DOMException — NAMESPACE_ERR: Raised if the qualifiedName
is a malformed qualified name, if the qualifiedName has a prefix and the
namespaceURI is null, or if the qualifiedName has a prefix that is "xml"
and the namespaceURI is different from
"http://www.w3.org/XML/1998/namespace" [XML Namespaces], or if the
qualifiedName or its prefix is "xmlns" and the namespaceURI is different
from "http://www.w3.org/2000/xmlns/", or if the namespaceURI is
"http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its
prefix is "xmlns".
| |
DOMException — NOT_SUPPORTED_ERR: Always thrown if the
current document does not support the "XML" feature, since namespaces
were defined by XML.
|
See also
<?xml version="1.0"?> <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" title="||Working with elements||" onload="init()"> <script type="text/javascript"><![CDATA[ var container; var newdiv; var txtnode; function init(){ container = document.getElementById("ContainerBox"); newdiv = document.createElementNS("http://www.w3.org/1999/xhtml","html:div"); txtnode = document.createTextNode("This is text that was constructed dynamically with createElementNS and createTextNode then inserted into the document using appendChild."); newdiv.appendChild(txtnode); container.appendChild(newdiv); } ]]></script> <vbox id='ContainerBox' flex='1'> <html:div> The script on this page will add dynamic content below: </html:div> </vbox> </page>
The example given above uses inline script which is not recommended in XHTML documents. This particular example is actually an XUL document with embedded XHTML, however, the recommendation still applies. Inline script does not cause any problems for this short example, however, for any serious work you should learn about Properly Using CSS and JavaScript in XHTML Documents.
DOM 1 Core createEntityReference | () | method |
public function createEntityReference(name:DOMString):EntityReference
Introduced in: | DOM 1 Core |
Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.
Note: If any descendant of the Entity node has an unbound namespace prefix, the corresponding descendant of the created EntityReference node is also unbound; (its namespaceURI is null). The DOM Level 2 and 3 do not support any mechanism to resolve namespace prefixes in this case.
Parameters
name:DOMString — The name of the entity to reference.
Unlike Document.createElementNS or Document.createAttributeNS, no
namespace well-formed checking is done on the entity name. Applications
should invoke Document.normalizeDocument() with the parameter "namespaces"
set to true in order to ensure that the entity name is namespace well-formed.
|
EntityReference — The new EntityReference object.
|
DOMException — INVALID_CHARACTER_ERR: Raised if the
specified name is not an XML name according to the XML version in
use specified in the Document.xmlVersion attribute.
| |
DOMException — NOT_SUPPORTED_ERR: Raised if this document
is an HTML document.
|
See also
DOM 2 Events createEvent | () | method |
public function createEvent(eventType:DOMString):Event
Introduced in: | DOM 2 Events |
Creates an event object of the type specified.
Parameters
eventType:DOMString — The eventType parameter specifies the name of the
DOM Events interface to be supported by the created event object,
e.g. "Event", "MouseEvent", "MutationEvent" and so on. If the Event
is to be dispatched via the EventTarget.dispatchEvent() method the
appropriate event initialization method must be called after creation
in order to initialize the Event's values.
As an example, a user wishing to synthesize some kind of UIEvent would
invoke DocumentEvent.createEvent("UIEvent"). The UIEvent.initUIEventNS()
ethod could then be called on the newly created UIEvent object to
set the specific type of user interface event to be dispatched, DOMActivate
for example, and set its context information, e.g. UIEvent.detail in
this example.
For backward compatibility reason, "UIEvents", "MouseEvents", "MutationEvents",
and "HTMLEvents" feature names are valid values for the parameter eventType
and represent respectively the interfaces "UIEvent", "MouseEvent",
"MutationEvent", and "Event", and the characters 'a'..'z' are considered
equivalent to the characters 'A'..'Z'.
|
Event — The newly created event object.
|
See also
createEventObject | () | method |
public function createEventObject(existingEvent:Event = null):Event
Non-standard (Microsoft)
Generates an event object to pass event context information when you use the fireEvent method.
Parameters
existingEvent:Event (default = null ) — A object that specifies an existing event object on which to base the new object.
|
Event — Returns an event object.
|
See also
<html> <body> <script> function OuterClick() { if(event.expando == "from_inner") { alert("Event actually fired by clicking on inner DIV!") } else { alert("Event fired by clicking on outer DIV!") } } function InnerClick() { var eventObj = document.createEventObject(); // Set an expando property on the event object. This will be used by the // event handler to determine what element was clicked on. eventObj.expando = "from_inner"; parent.document.all.Outer.fireEvent("onclick",eventObj); event.cancelBubble = true; } </script> <div id="Outer" onclick="OuterClick()" style="height:200;width:200;padding:50;background-color:mistyrose"> <div id="Inner" onclick="InnerClick()" style="height:100;width:100;padding:25;background-color:lavender"></div> </div> </body> </html>
DOM 3 Load and Save createLSInput | () | method |
public function createLSInput():LSInput
Introduced in: | DOM 3 Load and Save |
Create a new empty input source object where LSInput.characterStream, LSInput.byteStream, LSInput.stringData LSInput.systemId, LSInput.publicId, LSInput.baseURI, and LSInput.encoding are null, and LSInput.certifiedText is false.
ReturnsLSInput — The newly created input object.
|
See also
DOM 3 Load and Save createLSOutput | () | method |
public function createLSOutput():LSOutput
Introduced in: | DOM 3 Load and Save |
Create a new empty output destination object where LSOutput.characterStream, LSOutput.byteStream, LSOutput.systemId, LSOutput.encoding are null.
ReturnsLSOutput — The newly created output object.
|
See also
DOM 3 Load and Save createLSParser | () | method |
public function createLSParser(mode:Number, schemaType:DOMString):LSParser
Introduced in: | DOM 3 Load and Save |
Create a new LSParser. The newly constructed parser may then be configured by means of its DOMConfiguration object, and used to parse documents by means of its parse method.
Parameters
mode:Number — The mode argument is either MODE_SYNCHRONOUS or MODE_ASYNCHRONOUS, if mode is
MODE_SYNCHRONOUS then the LSParser that is created will operate in synchronous mode, if it's
MODE_ASYNCHRONOUS then the LSParser that is created will operate in asynchronous mode.
| |
schemaType:DOMString — An absolute URI representing the type of the schema language used during
the load of a Document using the newly created LSParser. Note that no lexical checking is done
on the absolute URI. In order to create a LSParser for any kind of schema types (i.e. the LSParser
will be free to use any schema found), use the value null.
Note: For W3C XML Schema [XML Schema Part 1], applications must use the value "http://www.w3.org/2001/XMLSchema". For XML DTD [XML 1.0], applications must use the value "http://www.w3.org/TR/REC-xml". Other Schema languages are outside the scope of the W3C and therefore should recommend an absolute URI in order to use this method. |
LSParser — The newly created LSParser object. This LSParser is either synchronous or asynchronous depending on the value of the mode argument.
Note: By default, the newly created LSParser does not contain a DOMErrorHandler, i.e. the value of the "error-handler" configuration parameter is null. However, implementations may provide a default error handler at creation time. In that case, the initial value of the "error-handler" configuration parameter on the new LSParser object contains a reference to the default error handler. |
See also
DOM 3 Load and Save createLSSerializer | () | method |
public function createLSSerializer():LSSerializer
Introduced in: | DOM 3 Load and Save |
Create a new LSSerializer object.
ReturnsLSSerializer — The newly created LSSerializer object.
Note: By default, the newly created LSSerializer has no DOMErrorHandler, i.e. the value of the "error-handler" configuration parameter is null. However, implementations may provide a default error handler at creation time. In that case, the initial value of the "error-handler" configuration parameter on the new LSSerializer object contains a reference to the default error handler. |
See also
DOM 2 TR createNodeIterator | () | method |
public function createNodeIterator(root:Node, whatToShow:Number, filter:NodeFilter, entityReferenceExpansion:Boolean):NodeIterator
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 2 Core |
Create a new NodeIterator over the subtree rooted at the specified node.
Parameters
root:Node — The node which will be iterated together with its children. The iterator is initially positioned
just before this node. The whatToShow flags and the filter, if any, are not considered when setting this position. The root must not be null .
| |
whatToShow:Number — This flag specifies which node types may appear in the logical view of the tree presented
by the iterator. These flags can be combined using OR.
| |
filter:NodeFilter — The NodeFilter to be used with this TreeWalker , or null to indicate no filter.
| |
entityReferenceExpansion:Boolean — The value of this flag determines whether entity reference nodes are expanded.
|
NodeIterator — The newly created NodeIterator.
|
See also
var nodeIterator = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); var nodeList = new Array(); var currentNode; while (currentNode = nodeIterator.nextNode()) { nodeList.push(currentNode); }
DOM 1 Core createProcessingInstruction | () | method |
public function createProcessingInstruction(target:DOMString, data:DOMString):ProcessingInstruction
Introduced in: | DOM 1 Core |
Creates a ProcessingInstruction node given the specified name and data strings.
Parameters
target:DOMString — The target part of the processing instruction.
Unlike Document.createElementNS or Document.createAttributeNS, no namespace
well-formed checking is done on the target name. Applications should invoke
Document.normalizeDocument() with the parameter "namespaces" set to true in
order to ensure that the target name is namespace well-formed.
| |
data:DOMString — The data for the node.
|
ProcessingInstruction — The new ProcessingInstruction object.
|
DOMException — INVALID_CHARACTER_ERR: Raised if the specified
target is not an XML name according to the XML version in use specified in
the Document.xmlVersion attribute.
| |
DOMException — NOT_SUPPORTED_ERR: Raised if this document is
an HTML document.
|
See also
var docu = new DOMParser().parseFromString('<xml></xml>', "application/xml"); var pi = docu.createProcessingInstruction('xml-stylesheet', 'href="mycss.css" type="text/css"'); docu.getElementsByTagName('xml')[0].appendChild(pi); alert(new XMLSerializer().serializeToString(docu)); // Displays: <xml><?xml-stylsheet href="mycss.css" type="text/css"?></xml>
DOM 2 TR createRange | () | method |
public function createRange():Range
Introduced in: | DOM 2 Core |
This interface can be obtained from the object implementing the Document interface using binding-specific casting methods.
ReturnsRange — The initial state of the Range returned from this method is such that both of its boundary-points
are positioned at the beginning of the corresponding Document, before any content. The Range returned can
only be used to select content associated with this Document, or with DocumentFragments and Attrs for which
this Document is the ownerDocument.
|
See also
var range = document.createRange(); range.setStart(startNode, startOffset); range.setEnd(endNode, endOffset);
createStyleSheet | () | method |
public function createStyleSheet(url:DOMString = null, index:Number):StyleSheet
Non-standard (Microsoft)
Creates a style sheet for the document.
Note (IE): You can create up to 31 styleSheet objects with the createStyleSheet method. After that, the method returns an "Invalid Argument" exception. To create additional objects, use createElement and append them to the HEAD of the document as follows:
var styleSheet = document.createElement('STYLE'); document.documentElement.firstChild.appendChild(styleSheet);
Parameters
url:DOMString (default = null ) — Specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object.
| |
index:Number (default = NaN ) — The index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection.
|
StyleSheet — Returns a styleSheet object.
|
See also
document.createStyleSheet('styles.css');
DOM 1 Core createTextNode | () | method |
public function createTextNode(data:DOMString):Text
Introduced in: | DOM 1 Core |
Creates a Text node given the specified string.
Parameters
data:DOMString — The data for the node.
|
Text — The new Text object.
|
See also
<html> <head> <title>createTextNode example</title> <script type="text/javascript"> function addTextNode() { var newtext = document.createTextNode(" Some text added dynamically. "); var para = document.getElementById("p1"); para.appendChild(newtext); } </script> </head> <body> <div style="border: 1px solid red"> <p id="p1">First line of paragraph.<br /></p> </div><br /> <button onclick="addTextNode();">add another textNode.</button> </body> </html>
DOM 2 TR createTreeWalker | () | method |
public function createTreeWalker(root:Node, whatToShow:Number, filter:NodeFilter, entityReferenceExpansion:Boolean):TreeWalker
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 2 Core |
Create a new TreeWalker over the subtree rooted at the specified node.
Parameters
root:Node — The node which will serve as the root for the TreeWalker. The whatToShow flags and the NodeFilter
are not considered when setting this value; any node type will be accepted as the root . The currentNode of the
TreeWalker is initialized to this node, whether or not it is visible. The root functions as a stopping point for
traversal methods that look upward in the document structure, such as parentNode and nextNode. The root must not
be null .
| |
whatToShow:Number — This flag specifies which node types may appear in the logical view of the tree presented by
the tree-walker. These flags can be combined using OR.
| |
filter:NodeFilter — The NodeFilter to be used with this TreeWalker , or null to indicate no filter.
| |
entityReferenceExpansion:Boolean — If this flag is false, the contents of EntityReference nodes are not presented in the logical view.
|
TreeWalker — The newly created TreeWalker .
|
See also
var treeWalker = document.createTreeWalker( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); var nodeList = new Array(); while(treeWalker.nextNode()) nodeList.push(treeWalker.currentNode);
detachEvent | () | method |
public function detachEvent(type:DOMString, listener:Function):void
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Non-standard (Microsoft)
Unbinds the specified function from the event, so that the function stops receiving notifications when the event fires.
Note (IE): Behaviors that attach to events using the attachEvent method must explicitly call the detachEvent method to stop receiving notifications from the page when the ondetach event fires. Behaviors that attach to events using the PUBLIC:ATTACH element automatically stop receiving notifications when the behavior detaches from the element, and thus do not need to call the detachEvent method.
Parameters
type:DOMString — Specifies any of the standard DHTML Events.
| |
listener:Function — Specifies the function previously set using the attachEvent method.
|
See also
<PUBLIC:ATTACH EVENT="ondetach" ONEVENT="cleanup()" /> <script language="JScript"> attachEvent ('onmouseover', Hilite); attachEvent ('onmouseout', Restore); function cleanup() { detachEvent ('onmouseover', Hilite); detachEvent ('onmouseout', Restore); } function Hilite() { if (event.srcElement == element) { normalColor = style.color; runtimeStyle.color = "red"; runtimeStyle.cursor = "hand"; } } function Restore() { if (event.srcElement == element) { runtimeStyle.color = normalColor; runtimeStyle.cursor = ""; } } </script>
CSSOM View elementFromPoint | () | method |
public function elementFromPoint(x:Number, y:Number):Element
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.1b 3.0 3.1 4.0b 1.0 2.0 9.62 10.0a |
Introduced in: | DOM 0 |
Modified in: | DOM 3 Core |
Returns the element from the document whose elementFromPoint method is being called which is the topmost element which lies under the given point.
The point is specified via coordinates, in CSS pixels, relative to the upper-left-most point in the window or frame containing the document.
Note: If the element at the specified point belongs to another document (for example, an iframe's subdocument), the element in the DOM of the document the method is called on (in the iframe case, the iframe itself) is returned. If the element at the given point is anonymous or XBL generated content, such as a textbox's scroll bars, then the first non-anonymous ancestor element (for example, the textbox) is returned.
Note: If the specified point is outside the visible bounds of the document or either coordinate is negative, the result is null.
Note: The browsers do not entirely agree which mouse coordinates this method needs. IE and Firefox 3 need clientX/Y (relative to the viewport), while Opera and Safari need pageX/Y (relative to the document).
Parameters
x:Number — The X coordinate to check, in CSS pixels relative to the upper-left corner of the document's containing window or frame.
| |
y:Number — The Y coordinate to check, in CSS pixels relative to the upper-left corner of the document's containing window or frame.
|
Element — The element at x,y in the viewport
|
See also
<html> <head> <title>elementFromPoint example</title> <script type="text/javascript"> function changeColor(newColor) { elem = document.elementFromPoint(2, 2); elem.style.color = newColor; } </script> </head> <body> <p id="para1">Some text here</p> <button onclick="changeColor('blue');">blue</button> <button onclick="changeColor('red');">red</button> </body> </html>
CSSOM enableStylesheetsForSet | () | method |
public function enableStylesheetsForSet(name:DOMString):void
Introduced in: | CSSOM |
Invoking this method must change the disabled attribute on each StyleSheet object with a title in the styleSheets attribute, so that all those whose title matches the name argument are enabled, and all others are disabled. Title matches must be case-sensitive.
Invoking this method with the empty string value must disable all alternative and preferred style sheets (but does not change the state of persistent style sheets).
Invoking this method with the null value must have no effect.
Style sheets that do not have a title are never affected by this method. This method does not change the values of the lastStyleSheetSet or preferredStyleSheetSet attributes.
Parameters
name:DOMString |
See also
DOM 1 Core getElementsByTagName | () | method |
public function getElementsByTagName(tagname:DOMString):NodeList
Introduced in: | DOM 1 Core |
Returns a NodeList of all the Elements in document order with a given tag name and are contained in the document.
Parameters
tagname:DOMString — The name of the tag to match on. The special
value "*" matches all tags. For XML, the tagname parameter is
case-sensitive, otherwise it depends on the case-sensitivity of
the markup language in use.
|
NodeList — A new NodeList object containing all the matched Elements.
|
See also
DOM 2 Core getElementsByTagNameNS | () | method |
public function getElementsByTagNameNS(namespaceURI:DOMString, localName:DOMString):NodeList
Introduced in: | DOM 2 Core |
Returns a NodeList of all the Elements with a given local name and namespace URI in document order.
Parameters
namespaceURI:DOMString — The namespace URI of the elements to match on.
The special value "*" matches all namespaces.
| |
localName:DOMString — The local name of the elements to match on. The
special value "*" matches all local names.
|
NodeList — A new NodeList object containing all the matched Elements.
|
See also
DOM 1 HTML getElemenyById | () | method |
public function getElemenyById(elementId:DOMString):Element
Introduced in: | DOM 1 HTML |
Modified in: | DOM 2 Core |
Returns the Element that has an ID attribute with the given value. If no such element exists, this returns null. If more than one element has an ID attribute with that value, what is returned is undefined.
Note: Attributes with the name "ID" or "id" are not of type ID unless so defined.
Note: Simply creating an element and assigning an ID will not make the element accessible by getElementById. Instead one needs to insert the element first into the document tree with insertBefore or a similar method, probably into a hidden div.
var element = document.createElement("div"); element.id = 'testqq'; var el = document.getElementById('testqq'); // el will be null!
Note (IE): In IE8 mode, getElementById performs a case-sensitive match on the ID attribute only. In IE7 mode and previous modes, this method performs a case-insensitive match on both the ID and NAME attributes, which might produce unexpected results.
Parameters
elementId:DOMString — The unique id value for an element.
|
Element — The matching element or null if there is none.
|
See also
<html> <head> <title>getElementById example</title> <script type="text/javascript"> function changeColor(newColor) { elem = document.getElementById("para1"); elem.style.color = newColor; } </script> </head> <body> <p id="para1">Some text here</p> <button onclick="changeColor('blue');">blue</button> <button onclick="changeColor('red');">red</button> </body> </html>
DOM 2 Style getOverrideStyle | () | method |
public function getOverrideStyle(elt:Element, pseudoElt:DOMString):CSSStyleDeclaration
Introduced in: | DOM 2 Core |
This method is used to retrieve the override style declaration for a specified element and a specified pseudo-element.
Parameters
elt:Element — The element whose style is to be modified. This parameter cannot be null.
| |
pseudoElt:DOMString — The pseudo-element or null if none.
|
CSSStyleDeclaration — The override style declaration.
|
See also
DOM 2 Core importNode | () | method |
public function importNode(importedNode:Node, deep:Boolean):Node
Introduced in: | DOM 2 Core |
Imports a node from another document to this document, without altering or removing the source node from the original document; this method creates a new copy of the source node. The returned node has no parent; (parentNode is null).
For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's nodeName and nodeType, plus the attributes related to namespaces (prefix, localName, and namespaceURI). As in the cloneNode operation, the source node is not altered. User data associated to the imported node is not carried over. However, if any UserDataHandlers has been specified along with the associated data these handlers will be called with the appropriate parameters before this method returns.
Additional information is copied as appropriate to the nodeType, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case. The following list describes the specifics for each type of node.
Node Type | Description |
---|---|
ATTRIBUTE_NODE | The ownerElement attribute is set to null and the specified flag is set to true on the generated Attr. The descendants of the source Attr are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note that the deep parameter has no effect on Attr nodes; they always carry their children with them when imported. |
DOCUMENT_FRAGMENT_NODE | If the deep option was set to true, the descendants of the source DocumentFragment are recursively imported and the resulting nodes reassembled under the imported DocumentFragment to form the corresponding subtree. Otherwise, this simply generates an empty DocumentFragment. |
DOCUMENT_NODE | Document nodes cannot be imported. |
DOCUMENT_TYPE_NODE | DocumentType nodes cannot be imported. |
ELEMENT_NODE | Specified attribute nodes of the source element are imported, and the generated Attr nodes are attached to the generated Element. Default attributes are not copied, though if the document being imported into defines default attributes for this element name, those are assigned. If the importNode deep parameter was set to true, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree. |
ENTITY_NODE | Entity nodes can be imported, however in the current release of the DOM the DocumentType is readonly. Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM. On import, the publicId, systemId, and notationName attributes are copied. If a deep import is requested, the descendants of the the source Entity are recursively imported and the resulting nodes reassembled to form the corresponding subtree. |
ENTITY_REFERENCE_NODE | Only the EntityReference itself is copied, even if a deep import is requested, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned. |
NOTATION_NODE | Notation nodes can be imported, however in the current release of the DOM the DocumentType is readonly. Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM. On import, the publicId and systemId attributes are copied. Note that the deep parameter has no effect on this type of nodes since they cannot have any children. |
PROCESSING_INSTRUCTION_NODE | The imported node copies its target and data values from those of the source node. Note that the deep parameter has no effect on this type of nodes since they cannot have any children. |
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE | These three types of nodes inheriting from CharacterData copy their data and length attributes from those of the source node. Note that the deep parameter has no effect on these types of nodes since they cannot have any children. |
Note: The original node is not removed from the original document. The imported node is a clone of the original.
Parameters
importedNode:Node — The node to import.
| |
deep:Boolean — If true, recursively import the subtree under the specified node; if false, import only
the node itself, as explained above. This has no effect on nodes that cannot have any children, and on
Attr, and EntityReference nodes.
|
Node — The imported node that belongs to this Document.
|
DOMException — NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported.
| |
DOMException — INVALID_CHARACTER_ERR: Raised if one of the imported names is not an XML name
according to the XML version in use specified in the Document.xmlVersion attribute. This may happen when
importing an XML 1.1 element into an XML 1.0 document, for instance.
|
See also
var iframe = document.getElementsByTagName("iframe")[0]; var oldNode = iframe.contentDocument.getElementById("myNode"); var newNode = document.importNode(oldNode,true); document.getElementById("container").appendChild(newNode);
DOM 3 Load and Save Obsolete load | () | method |
public function load(uri:DOMString):Boolean
Obsolete
Replaces the content of the document with the result of parsing the given URI. Invoking this method will either block the caller or return to the caller immediately depending on the value of the async attribute. Once the document is fully loaded the document will fire a "load" event that the caller can register as a listener for. If an error occurs the document will fire an "error" event so that the caller knows that the load failed (see ParseErrorEvent). If this method is called on a document that is currently loading, the current load is interrupted and the new URI load is initiated.
Note (Mozilla): As of at least Gecko 1.9, this no longer supports cross-site loading of documents (Use XMLHttpRequest instead).
Parameters
uri:DOMString — The URI reference for the XML file to be loaded. If this is a relative URI, the base URI used by the implementation is implementation dependent.
|
Boolean — If async is set to true load returns true if the document load was successfully initiated. If an
error occurred when initiating the document load load returns false. If async is set to false load returns
true if the document was successfully loaded and parsed. If an error occurred when either loading or parsing
the URI load returns false.
|
See also
var xmlDoc = document.implementation.createDocument("", "test", null); function documentLoaded (e) { alert(new XMLSerializer().serializeToString(e.target)); // Gives querydata.xml contents as string } xmlDoc.addEventListener("load", documentLoaded, false); xmlDoc.load('querydata.xml');
DOM 3 Load and Save Obsolete loadXML | () | method |
public function loadXML(source:DOMString):Boolean
Obsolete
Replace the content of the document with the result of parsing the input string, this method is always synchronous. This method always parses from a DOMString, which means the data is always UTF16. All other encoding information is ignored.
Parameters
source:DOMString — A string containing an XML document.
|
Boolean — true if parsing the input string succeeded without errors, otherwise false.
|
See also
DOM 3 Core normalizeDocument | () | method |
public function normalizeDocument():void
Introduced in: | DOM 3 Core |
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. See DOMConfiguration for details.
// Keep in the document the information defined // in the XML Information Set (Java example) DOMConfiguration docConfig = myDocument.getDomConfig(); docConfig.setParameter("infoset", Boolean.TRUE); myDocument.normalizeDocument();
Mutation events, when supported, are generated to reflect the changes occurring on the document. If errors occur during the invocation of this method, such as an attempt to update a read-only node or a Node.nodeName contains an invalid character according to the XML version in use, errors or warnings (DOMError.SEVERITY_ERROR or DOMError.SEVERITY_WARNING) will be reported using the DOMErrorHandler object associated with the "error-handler" parameter. Note this method might also report fatal errors (DOMError.SEVERITY_FATAL_ERROR) if an implementation cannot recover from an error.
See also
Selectors API querySelector | () | method |
public function querySelector(selectors:DOMString):Element
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0b |
Introduced in: | DOM 3 Core |
Returns the first element that is a descendent of the element on which it is invoked that matches the specified group of selectors.
Parameters
selectors:DOMString — One or more selectors
|
Element — The first matching Element node within the node’s subtree. If there is no such node, returns null.
|
See also
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Selectors API Example</title> </head> <body> <div id="foo"> <p class="warning">This is a sample warning</p> <p class="error">This is a sample error</p> </div> <div id="bar"> <p>...</p> </div> </body> </html>
var x = document.querySelector("#foo, #bar");
Selectors API querySelectorAll | () | method |
public function querySelectorAll(selectors:DOMString):NodeList
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0b |
Introduced in: | DOM 3 Core |
Returns a list of all elements descended from the element on which it is invoked that match the specified group of selectors.
Parameters
selectors:DOMString — One or more selectors
|
NodeList — A NodeList containing all of the matching Element nodes within the node’s subtree, in document order. If there are no such nodes, returns an empty NodeList.
|
See also
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Selectors API Example</title> </head> <body> <div id="foo"> <p class="warning">This is a sample warning</p> <p class="error">This is a sample error</p> </div> <div id="bar"> <p>...</p> </div> </body> </html>
var alerts = document.querySelectorAll("p.warning, p.error");
DOM 3 Core renameNode | () | method |
public function renameNode(n:Node, namespaceURI:DOMString, qualifiedName:DOMString):Node
Introduced in: | DOM 3 Core |
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,
Parameters
n:Node — The node to rename.
| |
namespaceURI:DOMString — The new namespace URI.
| |
qualifiedName:DOMString — The new qualified name.
|
Node — The renamed node. This is either the specified node or the new
node that was created to replace the specified node.
|
DOMException — NOT_SUPPORTED_ERR: Raised when the type of
the specified node is neither ELEMENT_NODE nor ATTRIBUTE_NODE, or if the
implementation does not support the renaming of the document element.
| |
DOMException — INVALID_CHARACTER_ERR: Raised if the new
qualified name is not an XML name according to the XML version in use
specified in the Document.xmlVersion attribute.
| |
DOMException — WRONG_DOCUMENT_ERR: Raised when the specified
node was created from a different document than this document.
| |
DOMException — NAMESPACE_ERR: Raised if the qualifiedName is
a malformed qualified name, if the qualifiedName has a prefix and the
namespaceURI is null, or if the qualifiedName has a prefix that is "xml"
and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace"
XML Namespaces. Also raised, when the node being renamed is an attribute,
if the qualifiedName, or its prefix, is "xmlns" and the namespaceURI is
different from "http://www.w3.org/2000/xmlns/".
|
See also
DOM 3 Load and Save Obsolete saveXML | () | method |
public function saveXML(snode:Node):DOMString
Obsolete
Save the document or the given node to a string (i.e. serialize the document or node).
Parameters
snode:Node — Specifies what to serialize, if this parameter is null the whole document is serialized, if it's non-null the given node is serialized.
|
DOMString — The serialized document or null.
|
See also
updateSettings | () | method |
public function updateSettings():void
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0b |
Non-standard (Microsoft)
Allows updating the print settings for the page.
See also
DOMSubtreeModified | Event |
dom.events.MutationEvent
DOMSubtreeModified
This is a general event for notification of all changes to the document. It can be used instead of the more specific mutation and mutation name events listed below. It may be dispatched after a single modification to the document or, at the implementation's discretion, after multiple changes have occurred. The latter use should generally be used to accommodate multiple changes which occur either simultaneously or in rapid succession. The target of this event is the lowest common parent of the changes which have taken place. This event is dispatched after any other events caused by the mutation(s) have occurred.
load | Event |
dom.events.Event
load
The DOM Implementation finishes loading the resource (such as the document) and any dependent resources (such as images, style sheets, or scripts). Dependent resources that fail to load will not prevent this event from firing if the resource that loaded them is still accessible via the DOM. If this event type is dispatched, implementations are required to dispatch this event at least on the Document node.
mousemultiwheel | Event |
dom.events.MouseMultiWheelEvent
mousemultiwheel
A mouse wheel has been rotated. A default action of user agent generated event objects of this type causes implementations to dispatch a mousewheel event iff it supports that event type and MouseMultiWheelEvent.wheelDeltaY is non-zero.
mousewheel | Event |
dom.events.MouseWheelEvent
mousewheel
A mouse wheel has been rotated around the y-axis.
offline | Event |
dom.events.Event
offline
Is fired when the browser switches between online and offline mode.
online | Event |
dom.events.Event
online
Is fired when the browser switches between online and offline mode.
resize | Event |
dom.events.Event
resize
A document view or an element has been resized. The resize occured before the dispatch of this event type.
scroll | Event |
dom.events.Event
scroll
A document view or an element has been scrolled. The scroll occured before the dispatch of this event type.
unload | Event |
dom.events.Event
unload
The DOM implementation removes from the environment the resource (such as the document) or any dependent resources (such as images, style sheets, scripts). The document is unloaded after the dispatch of this event type. If this event type is dispatched, implementations are required to dispatch this event at least on the Document node.