Package | dom.html |
Class | public class HTMLDocument |
Inheritance | HTMLDocument Document Node Object |
Implements | XPathEvaluator |
Introduced in: | DOM 0 |
Modified in: | HTML 5 |
Besides providing access to the hierarchy, it also provides some convenience methods for accessing certain sets of information from the document.
The following properties have been deprecated in favor of the corresponding ones for the BODY element:
See also
Property | Defined By | ||
---|---|---|---|
HTML 5 activeElement : Element [read-only]
Returns the currently focused element. | HTMLDocument | ||
Deprecated alinkColor : DOMString
Returns or sets the color of an active link in the document body. | HTMLDocument | ||
Non-Standard all : HTMLCollection [read-only]
Returns a reference to the collection of elements contained by the object. | HTMLDocument | ||
DOM 1 HTML anchors : HTMLCollection [read-only]
A collection of all the anchor (A) elements in a document with a
value for the name attribute. | HTMLDocument | ||
DOM 1 HTML applets : HTMLCollection [read-only]
A collection of all the OBJECT elements that include applets and
APPLET (deprecated) elements in a document. | HTMLDocument | ||
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 | ||
Deprecated background : DOMString
URI of the background texture tile image. | HTMLDocument | ||
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 | ||
Non-Standard baseURIObject : nsIURI [read-only]
baseURIObject returns the nsIURI object representing the document's URI. | HTMLDocument | ||
Deprecated bgColor : DOMString
Gets/sets the background color of the current document. | HTMLDocument | ||
DOM 1 HTML body : HTMLElement
The element that contains the content for the document. | HTMLDocument | ||
DOM 0 characterSet : DOMString
Returns the character encoding of the current document. | HTMLDocument | ||
HTML 5 charset : DOMString
Sets or retrieves the character set used to encode the object. | HTMLDocument | ||
DOM 1 Core childNodes : NodeList [read-only]
Returns an ordered collection of node objects that are children of
the current element. | Node | ||
Non-Standard compatible : HTMLCollection [read-only]
Retrieves the collection of user agents and versions declared in the X-UA-Compatible meta tag. | HTMLDocument | ||
HTML 5 compatMode : DOMString
Indicates whether the document is rendered in Quirks mode or Strict mode. | HTMLDocument | ||
Non-Standard contentType : DOMString [read-only]
Returns the Content-Type from the HTTP headers of the document. | HTMLDocument | ||
DOM 0 cookie : DOMString
Get and set the cookies associated with the current document. | HTMLDocument | ||
Non-Standard dataType : *
Specifies the data type for this node. | Node | ||
HTML 5 defaultCharset : DOMString [read-only]
Gets the default character set from the current regional language settings. | HTMLDocument | ||
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 | ||
Non-Standard designMode : DOMString
Sets or gets a value that indicates whether the document can be edited. | HTMLDocument | ||
Non-Standard dir : DOMString
Sets or retrieves a value that indicates the reading order of the object. | HTMLDocument | ||
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 | ||
Non-Standard documentMode : Number [read-only]
Retrieves the document compatibility mode of the document. | HTMLDocument | ||
DOM 3 Core documentURI : DOMString
The location of the document or null if undefined or if the Document was
created using DOMImplementation.createDocument. | Document | ||
Non-Standard documentURIObject : nsIURI [read-only]
Returns an nsIURI object representing the URI of the document. | HTMLDocument | ||
DOM 1 HTML domain : DOMString
Gets/sets the domain of the current document. | HTMLDocument | ||
DOM 3 Core domConfig : DOMConfiguration [read-only]
The configuration used when Document.normalizeDocument() is invoked. | Document | ||
DOM 0 embeds : HTMLCollection [read-only]
Retrieves a collection of all embed objects in the document. | HTMLDocument | ||
Non-Standard expando : Boolean
Sets or retrieves a value indicating whether arbitrary variables can be created within the object. | HTMLDocument | ||
Deprecated fgColor : DOMString
Gets/sets the foreground color, or text color, of the current document. | HTMLDocument | ||
Non-Standard fileCreatedDate : DOMString [read-only]
Retrieves the date the file was created. | HTMLDocument | ||
Non-Standard fileModifiedDate : DOMString [read-only]
Retrieves the date the file was last modified. | HTMLDocument | ||
Non-Standard fileSize : DOMString [read-only]
Retrieves the file size. | HTMLDocument | ||
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 HTML forms : HTMLCollection [read-only]
A collection of all the forms of a document. | HTMLDocument | ||
Non-Standard frames : HTMLCollection [read-only]
Retrieves a collection of all window objects defined by the given document or defined by
the document associated with the given window. | HTMLDocument | ||
DOM 0 height : Number
Returns the height of the body element of the current document. | HTMLDocument | ||
DOM 1 HTML images : HTMLCollection [read-only]
A collection of all the IMG elements in a document. | HTMLDocument | ||
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 | ||
DOM 0 lastModified : DOMString [read-only]
Returns a string containing the date and time on which the current document was last modified, in the form "MM/DD/YY hh:mm:ss". | HTMLDocument | ||
CSSOM lastStyleSheetSet : DOMString [read-only]
This attribute must initially have the value null. | Document | ||
Deprecated linkColor : DOMString
Gets/sets the color of links within the document. | HTMLDocument | ||
DOM 1 HTML links : HTMLCollection [read-only]
A collection of all AREA elements and anchor (A) elements in a document
with a value for the href attribute. | HTMLDocument | ||
DOM 2 Core localName : DOMString [read-only]
Returns the local part of the qualified name of this node. | Node | ||
DOM 0 location : Location [read-only]
Returns a Location object, which contains information about the URL of the document and provides
methods for changing that URL. | HTMLDocument | ||
Non-Standard namespaces : HTMLCollection [read-only]
Retrieves a collection of namespace objects. | HTMLDocument | ||
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 parentWindow : Window [read-only]
Gets a reference to the container object of the window. | HTMLDocument | ||
Non-Standard parsed : Boolean [read-only]
Indicates the parsed status of the node and child nodes. | Node | ||
DOM 0 plugins : HTMLCollection [read-only]
Returns an HTMLCollection object containing one or more HTMLEmbedElements or null which represent the <embed> elements in the current document. | HTMLDocument | ||
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 | ||
Non-Standard protocol : DOMString
Sets or retrieves the protocol portion of a URL. | HTMLDocument | ||
HTML 5 readyState : DOMString [read-only]
Retrieves a value that indicates the current state of the object. | HTMLDocument | ||
DOM 1 HTML referrer : DOMString [read-only]
Returns the URI of the page that linked to this page. | HTMLDocument | ||
HTML 5 scripts : HTMLCollection [read-only]
Returns an HTMLCollection object containing one or more HTMLScriptElements or null which represent the <script> elements in the current document. | HTMLDocument | ||
CSSOM selectedStyleSheetSet : DOMString
This attribute indicates which style sheet set is in use. | Document | ||
Non-Standard selection : Selection [read-only]
Represents the active selection, which is a highlighted block of text or other elements in the document
that a user or a script can carry out some action on. | HTMLDocument | ||
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 | ||
DOM 1 HTML title : DOMString
Gets or sets the title of the document. | HTMLDocument | ||
Non-Standard uniqueID : DOMString [read-only]
Retrieves an autogenerated, unique identifier for the object. | HTMLDocument | ||
DOM 1 HTML URL : DOMString [read-only]
Returns the URL of the current document. | HTMLDocument | ||
Non-Standard URLUnencoded : DOMString [read-only]
Gets the URL for the document, stripped of any character encoding. | HTMLDocument | ||
Deprecated vlinkColor : DOMString
Gets/sets the color of links that the user has visited in the document. | HTMLDocument | ||
DOM 0 width : Number
Returns the width of the body element of the current document in pixels. | HTMLDocument | ||
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 | ||
Non-Standard XSLDocument : DOMObject [read-only]
Retrieves a reference to the top-level node of the Extensible Stylesheet Language (XSL) document. | HTMLDocument |
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 | ||
Instructs the browser to grab events of a specific type before they reach their intended target document objects. | HTMLDocument | ||
Deprecated clear():void
This method used to clear the whole specified document in early (pre-1.0)
versions of Mozilla. | HTMLDocument | ||
Returns a duplicate of the current node. | Node | ||
DOM 1 HTML close():void
Closes a document stream opened by open() and forces rendering. | HTMLDocument | ||
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 | ||
Creates a parsed XPath expression with resolved namespaces. | HTMLDocument | ||
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 | ||
Adapts any DOM node to resolve namespaces so that an XPath expression can be easily evaluated
relative to the context of the node where it appeared within the document. | HTMLDocument | ||
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 | ||
DOM 3 XPath evaluate(expression:DOMString, contextNode:Node, resolver:XPathNSResolver, type:Number, result:DOMObject):DOMObject
Evaluates an XPath expression string and returns a result of the specified type if possible. | HTMLDocument | ||
Non-Standard execCommand(aCommandName:DOMString, aShowDefaultUI:Boolean, aValueArgument:DOMString):Boolean
When an HTML document has been switched to designMode, the document object exposes the execCommand
method which allows one to run commands to manipulate the contents of the editable region. | HTMLDocument | ||
Displays help information for the given command identifier. | HTMLDocument | ||
Fires a specified event on the object. | HTMLDocument | ||
Non-Standard focus():void
Causes the element to receive the focus and executes the code specified by the onfocus event. | HTMLDocument | ||
This particular method was a way for XUL elements to efficiently determine their position, amongst other things. | HTMLDocument | ||
Returns a set of elements with the given class name. | HTMLDocument | ||
Returns a list of elements with a given name in the (X)HTML document. | HTMLDocument | ||
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 | ||
Return the contents of selected text in the current document. | HTMLDocument | ||
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 | ||
HTML 5 hasFocus():Boolean
The hasFocus method returns true if the focus is currently located anywhere inside the specified document. | HTMLDocument | ||
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 | ||
Open a document stream for writing. | HTMLDocument | ||
Determines whether the given command can be executed on the document in its current state. | HTMLDocument | ||
Determines whether the current selection is in an indetermined state. | HTMLDocument | ||
Determines whether the given command has been executed on the current selection. | HTMLDocument | ||
Returns a Boolean value that indicates whether the current command is supported on the current range. | HTMLDocument | ||
Retrieves the string associated with a command. | HTMLDocument | ||
Determines the current value of the document, range, or current selection for the given command. | HTMLDocument | ||
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 | ||
Non-Standard recalc(forceAll:Boolean):void
Recalculates all dynamic properties in the current document. | HTMLDocument | ||
Non-Standard releaseCapture():void
Removes mouse capture from the object in the current document. | HTMLDocument | ||
The opposite of document.captureEvents( ), this method turns off event capture at the document level for
one or more specific events named in the parameter list. | HTMLDocument | ||
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 | ||
Removes the object from the document hierarchy. | HTMLDocument | ||
Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE. | Document | ||
Replaces an existing child element with a new child element. | Node | ||
Replaces the object with another element. | HTMLDocument | ||
Used inside an event handler function, this method lets the event pass to its intended target object. | HTMLDocument | ||
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 | ||
Exchanges the location of two objects in the document hierarchy. | HTMLDocument | ||
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 | ||
Write a string of text to a document stream opened by open(). | HTMLDocument | ||
Write a string of text followed by a newline character to a document
stream opened by open(). | HTMLDocument |
HTML 5 activeElement | property |
activeElement:Element
[read-only] Introduced in: | HTML 5 |
Returns the currently focused element.
If no element in the Document is focused, this will return the body element.
Note: This attribute is part of the in-development HTML 5 specification.
Note (IE): For versions of Microsoft Internet Explorer 5 and later, the activeElement property is not defined until a document is loaded. A value of null is given for this property, if it is accessed inline during the loading of a document. This property can be accessed in the onload event handler function.
Note (IE): Internet Explorer 4.0 returns body as the activeElement when it is accessed inline during the loading of a document.
public function get activeElement():Element
See also
alinkColor | property |
alinkColor:DOMString
Introduced in: | DOM 0 |
Deprecated since DOM Level 2 HTML
Returns or sets the color of an active link in the document body. A link is active during the time between mousedown and mouseup events.
Note: The color is a string representing the color as a word (e.g., "red") or hexadecimal value (e.g., "#ff0000").
Note: Gecko supports both alinkColor/:active and :focus . Internet Explorer 6 and 7 support alinkColor/:active only for HTML anchor (<a>) links and the behavior is the same as :focus under Gecko. There is no support for :focus in IE.
The default value is "#0000FF" for IE / "#EE0000" for Mozilla
.
public function get alinkColor():DOMString
public function set alinkColor(value:DOMString):void
See also
all | property |
all:HTMLCollection
[read-only] Non-standard (Microsoft)
Returns a reference to the collection of elements contained by the object.
Note: The all collection includes one element object for each valid HTML tag. If a valid tag has a matching end tag, both tags are represented by the same element object.
Note: The collection returned by the document's all collection always includes a reference to the HTML, HEAD, and TITLE objects regardless of whether the tags are present in the document. If the BODY tag is not present, but other HTML tags are, a BODY object is added to the all collection.
Note: If the document contains invalid or unknown tags, the collection includes one element object for each. Unlike valid end tags, unknown end tags are represented by their own element objects. The order of the element objects is the HTML source order. Although the collection indicates the order of tags, it does not indicate hierarchy.
Note: The name property only applies to some elements such as form elements. If the vIndex is set to a string matching the value of a name property in an element that the name property does not apply, then that element will not be added to the collection.
public function get all():HTMLCollection
See also
for(i = 0; i < document.all.length; i++) { alert(document.all(i).tagName); }
DOM 1 HTML anchors | property |
anchors:HTMLCollection
[read-only] Introduced in: | DOM 1 HTML |
A collection of all the anchor (A) elements in a document with a value for the name attribute.
Note: For reasons of backwards compatibility, the returned set of anchors only contains those anchors created with the name attribute, not those created with the id attribute.
public function get anchors():HTMLCollection
See also
if ( document.anchors.length >= 5 ) { dump("dump found too many anchors"); window.location = "http://www.google.com"; }
DOM 1 HTML applets | property |
applets:HTMLCollection
[read-only] Introduced in: | DOM 1 HTML |
A collection of all the OBJECT elements that include applets and APPLET (deprecated) elements in a document.
public function get applets():HTMLCollection
See also
// ( When you know the second applet is the one you want ) my_java_app = document.applets[1];
background | property |
background:DOMString
Introduced in: | DOM 0 |
Deprecated since DOM Level 2 HTML
URI of the background texture tile image.
public function get background():DOMString
public function set background(value:DOMString):void
baseURIObject | property |
baseURIObject:nsIURI
[read-only] Non-standard (Mozilla)
baseURIObject returns the nsIURI object representing the document's URI.
Note (Mozilla): This property exists on all nodes (HTML, XUL, SVG, MathML, etc.), but only if the script trying to use it has UniversalXPConnect privileges.
Note (Mozilla): This property may only be accessed from privileged code.
public function get baseURIObject():nsIURI
See also
bgColor | property |
bgColor:DOMString
Introduced in: | DOM 0 |
Deprecated since DOM Level 2 HTML
Gets/sets the background color of the current document.
Note: The color is a string representing the color as a word (e.g., "red") or hexadecimal value (e.g., "#ff0000").
The default value is "#ffffff"
.
public function get bgColor():DOMString
public function set bgColor(value:DOMString):void
See also
DOM 1 HTML body | property |
body:HTMLElement
Introduced in: | DOM 1 HTML |
The element that contains the content for the document. In documents with BODY contents, returns the BODY element. In frameset documents, this returns the outermost FRAMESET element.
Note: Though body is settable, setting a new body on a document will effectively remove all the current children of the existing </body> element.
public function get body():HTMLElement
public function set body(value:HTMLElement):void
See also
// in HTML: <body id="oldBodyElement"></body> alert(document.body.id); // "oldBodyElement" var aNewBodyElement = document.createElement("body"); aNewBodyElement.id = "newBodyElement"; document.body = aNewBodyElement; alert(document.body.id); // "newBodyElement"
DOM 0 characterSet | property |
characterSet:DOMString
Returns the character encoding of the current document.
Note: The character encoding is the character set used for rendering the document, which may be different from the encoding specified by the page (the user can override the encoding).
public function get characterSet():DOMString
public function set characterSet(value:DOMString):void
See also
HTML 5 charset | property |
charset:DOMString
Introduced in: | Non-Standard |
Modified in: | HTML 5 |
Sets or retrieves the character set used to encode the object.
Note (IE): In Microsoft Internet Explorer 6, This property now applies to the a, link, and script objects.
public function get charset():DOMString
public function set charset(value:DOMString):void
See also
compatible | property |
compatible:HTMLCollection
[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 |
Non-standard (Microsoft)
Retrieves the collection of user agents and versions declared in the X-UA-Compatible meta tag.
Note (IE): This method is available in all compatibility modes.
public function get compatible():HTMLCollection
See also
<meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /> <script type="text/javascript"> window.attachEvent('onload',function(e) { var a = []; var compat = document.compatible; for (var i=0; i<compat.length; i++) { a.push(compat[i].userAgent + '=' + compat[i].version); } var o = document.getElementById('output'); o.innerHTML = a.join('<br/>'); }); </script> <div id="output"></div>
HTML 5 compatMode | property |
compatMode:DOMString
Introduced in: | Non-Standard |
Modified in: | HTML 5 |
Indicates whether the document is rendered in Quirks mode or Strict mode.
Note: Can either be "BackCompat" for Quirks mode or "CSS1Compat" for Strict mode.
Note: There is a third mode, Gecko's "Almost_Standards" Mode, which only differs from Strict mode in the layout of images inside table cells. This third mode is reported the same way as Strict mode: "CSS1Compat".
Note (IE): The compatMode property is deprecated in Internet Explorer 8 in favor of the documentMode property.
public function get compatMode():DOMString
public function set compatMode(value:DOMString):void
See also
if (document.compatMode == "BackCompat") { // use some quirky stuff }
contentType | property |
contentType:DOMString
[read-only] Non-standard (Mozilla)
Returns the Content-Type from the HTTP headers of the document.
Note (Mozilla): The property returns the MIME property "Content-Type" set in the HTTP Header and not the META property set in the HEAD section of the document.
public function get contentType():DOMString
See also
DOM 0 cookie | property |
cookie:DOMString
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 0 |
Modified in: | DOM 1 HTML |
Get and set the cookies associated with the current document.
allCookies = document.cookie;
allCookies
is a string containing a semicolon-separated list of cookies (i.e. key=value pairs)
document.cookie = updatedCookie;
updatedCookie
is a string of form key=value. Note that you can only set/update a single cookie at a time using this method.
Any of the following cookie attribute values can optionally follow the key-value pair, specifying the cookie to set/update, and preceded by a semi-colon separator:
;path=path
(e.g., '/', '/mydir') If not specified, defaults to the current path of the current document location.;domain=domain
(e.g., 'example.com', '.example.com' (includes all subdomains), 'subdomain.example.com') If not specified, defaults to the host portion of the current document location.;max-age=max-age-in-seconds
(e.g., 600465 for a year);expires=date-in-GMTString-format
(could use Date.toGMTString; now obsolete) If not specified it wil expire at the end of session.;secure
(cookie to only be transmitted over secure protocol as http)Note: The cookie value string can use encodeURIComponent() to ensure that the string does not contain any commas, semicolons, or whitespace (which are disallowed in cookie values).
public function get cookie():DOMString
public function set cookie(value:DOMString):void
DOMException — SYNTAX_ERR: If the new value does not adhere to the cookie syntax.
|
See also
document.cookie = "name=oeschger"; document.cookie = "favorite_food=tripe"; alert(document.cookie); // displays: name=oeschger;favorite_food=tripe
HTML 5 defaultCharset | property |
defaultCharset:DOMString
[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: | Non-Standard |
Modified in: | HTML 5 |
Gets the default character set from the current regional language settings.
Note (Microsoft): The value depends on the current regional language settings. For typical settings in North America, the value is windows-1252.
public function get defaultCharset():DOMString
See also
designMode | property |
designMode:DOMString
Non-standard (Microsoft/Mozilla)
Sets or gets a value that indicates whether the document can be edited.
Values can be:
Note (Mozilla): Gets/sets WYSYWIG editing capability of Midas. It can only be used for HTML documents.
Note (Mozilla): Midas is the code name for Gecko's built-in rich text editor. Midas can be enabled via JavaScript on an HTML document. When Midas is enabled, the document becomes editable by the user. Scripting for Midas is based on the DHTML commands supported by Internet Explorer.
Note (Microsoft): You can use the designMode property to put Windows Internet Explorer into a mode so that you can edit the current document.
Note (Microsoft): While the browser is in design mode, objects enter a UI-activated state when the user presses ENTER, clicks an object that has focus, or double-clicks the object. Objects that are UI-activated have their own window in the document. You can modify the UI only when the object is in a UI-activated state.
Note (Microsoft): You cannot execute script when the value of the designMode property is set to On.
Note: Since an entire document becomes editable, authors often load the editable document into an IFRAME and do the bulk of the scripting in the parent document.
public function get designMode():DOMString
public function set designMode(value:DOMString):void
See also
<html> <head> <title>Simple Edit Box</title> </head> <body> <iframe id="MidasForm" src="about:blank" onload="this.contentDocument.designMode='on';" ></iframe> </body> </html>
dir | property |
dir:DOMString
Non-standard (Microsoft/Mozilla)
Sets or retrieves a value that indicates the reading order of the object.
Values can be:
Note: The dir property does not affect alphanumeric characters in Latin documents. These characters always render ltr. However, the property does affect punctuation characters in Latin documents. For example, punctuation marks such as periods and question marks will render to the left of a sentence when the dir property is set to rtl.
Note: The value of dir property has no effect on the orientation of coordinates for an object's positioning properties. For example, the left property and the right property perform the same placement in both cases. However, when both the left and right properties are specified, the left property takes precedence when the dir property is set to ltr. Likewise, the right property takes precedence when the dir property is set to rtl.
public function get dir():DOMString
public function set dir(value:DOMString):void
See also
documentMode | property |
documentMode:Number
[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 |
Non-standard (Microsoft)
Retrieves the document compatibility mode of the document.
Possible Values:
Note (IE): The document compatibility mode of a Web page determines how Internet Explorer 8 interprets and renders the page. Page authors generally use meta elements to specify X-UA-Compatible HTTP-EQUIV headers that specify the document compatibility mode. For more information, see Defining Document Compatibility. In versions of Internet Explorer previous to Internet Explorer 8, compatMode was solely determined by DOCTYPE.
public function get documentMode():Number
See also
documentURIObject | property |
documentURIObject:nsIURI
[read-only] Non-standard (Mozilla)
Returns an nsIURI object representing the URI of the document.
This only works for privileged (UniversalXPConnect) scripts, including extension code. For web content this property doesn't have any special meaning and can be used just like any other custom property.
Privileged code must be careful not to try getting or setting this property on a non-wrapped content object (e.g. on a wrappedJSObject of an XPCNativeWrapper). See bug 324464's comments for details.
public function get documentURIObject():nsIURI
See also
// Check that the URI scheme of the current tab in Firefox is 'http', // assuming this code runs in context of browser.xul var uriObj = content.document.documentURIObject; var uriPort = uriObj.port; if (uriObj.schemeIs('http')) { ... }
DOM 1 HTML domain | property |
domain:DOMString
Introduced in: | DOM 1 HTML |
Gets/sets the domain of the current document.
Note: This property returns null if the domain of the document cannot be identified.
Note: In the DOM HTML specification, this property is listed as being read-only. However, all common browsers including Mozilla will let you set it to a superdomain of the current value. For example, on developer.mozilla.org it is possible to set it to "mozilla.org" but not "mozilla.com".
Note: It is not universally possible in all browsers to set document.domain to a top-level domain (such as "com" or "org") or to a subdomain of a domain on which registrations are restricted (e.g. "co.uk", as registrations on the "uk" domain are restricted).
public function get domain():DOMString
public function set domain(value:DOMString):void
See also
// for document www.love.com/good.html, // this script closes the window var badDomain = "www.love.com"; if (document.domain == badDomain) { window.close(); }
// For the URI http://developer.mozilla.org/en/docs/DOM the // following sets domain to the string "developer.mozilla.org" var domain = document.domain;
DOM 0 embeds | property |
embeds:HTMLCollection
[read-only] Introduced in: | DOM 0 |
Retrieves a collection of all embed objects in the document.
public function get embeds():HTMLCollection
See also
expando | property |
expando: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)
Sets or retrieves a value indicating whether arbitrary variables can be created within the object.
Note: You can extend the properties on an object by creating arbitrary properties with values. You should be careful, however, because you can unintentionally set a property value when scripting in a case-sensitive language such as Microsoft JScript. For example, if the property value is borderColor and you type the value "bordercolor = 'blue'", you have, in fact, created another property on the style object called bordercolor with the value 'blue'. If you query the value of the property, the value "blue" is returned. However, the borders for the element do not turn blue.
Note: Setting the expando property of the document object to false precludes the functionality of all expandos within the document.
The default value is true
.
public function get expando():Boolean
public function set expando(value:Boolean):void
See also
<html> <head> <script type="text/javascript"> //Set the expando property to false. document.expando = false; </script> </head> <body> <div> <span id="oSpan" unselectable="on">This text should be selectable.</span> </div> </body> </html>
fgColor | property |
fgColor:DOMString
Introduced in: | DOM 0 |
Deprecated since DOM Level 2 HTML
Gets/sets the foreground color, or text color, of the current document.
Note: The color is a string representing the color as a word (e.g., "red") or hexadecimal value (e.g., "#ff0000").
The default value is "#000000"
.
public function get fgColor():DOMString
public function set fgColor(value:DOMString):void
See also
fileCreatedDate | property |
fileCreatedDate:DOMString
[read-only] Non-standard (Microsoft)
Retrieves the date the file was created. For example, Monday, December 08, 1997.
public function get fileCreatedDate():DOMString
See also
// Date document was created var oCreated=new Date(document.fileCreatedDate); // Today's Date var oToday=new Date(); //There are 86400000 milliseconds in a day var iMilliSeconds=86400000; var iDaysBetween=(oToday.getTime() - oCreated.getTime()) / iMilliSeconds; alert("Created: " + oCreated + "\nDays since created: " + parseInt(iDaysBetween));
fileModifiedDate | property |
fileModifiedDate:DOMString
[read-only] Non-standard (Microsoft)
Retrieves the date the file was last modified. For example, Monday, December 08, 1997.
public function get fileModifiedDate():DOMString
See also
fileSize | property |
fileSize:DOMString
[read-only] Non-standard (Microsoft)
Retrieves the file size.
public function get fileSize():DOMString
See also
DOM 1 HTML forms | property |
forms:HTMLCollection
[read-only] Introduced in: | DOM 1 HTML |
A collection of all the forms of a document.
public function get forms():HTMLCollection
See also
<html> <head> <title> document.forms example</title> </head> <body> <form id="robby"> <input type="button" onclick="alert(document.forms[0].id);" value="robby's form" /> </form> <form id="dave"> <input type="button" onclick="alert(document.forms[1].id);" value="dave's form" /> </form> <form id="paul"> <input type="button" onclick="alert(document.forms[2].id);" value="paul's form" /> </form> </body> </html>
frames | property |
frames:HTMLCollection
[read-only] Non-standard (Microsoft)
Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window.
public function get frames():HTMLCollection
See also
DOM 0 height | property |
height:Number
Introduced in: | DOM 0 |
Returns the height of the body element of the current document.
public function get height():Number
public function set height(value:Number):void
See also
// alert document height alert(document.height);
DOM 1 HTML images | property |
images:HTMLCollection
[read-only] Introduced in: | DOM 1 HTML |
A collection of all the IMG elements in a document. The behavior is limited to IMG elements for backwards compatibility.
Note: As suggested by HTML 4.01, to include images, authors may use the OBJECT element or the IMG element. Therefore, it is recommended not to use this attribute to find the images in the document but getElementsByTagName with HTML 4.01 or getElementsByTagNameNS with XHTML 1.0.
public function get images():HTMLCollection
See also
var ilist = document.images; for(var i = 0; i < ilist.length; i++) { if(ilist[i] == "banner.gif") { // found the banner } }
DOM 0 lastModified | property |
lastModified:DOMString
[read-only] Introduced in: | DOM 0 |
Returns a string containing the date and time on which the current document was last modified, in the form "MM/DD/YY hh:mm:ss".
Note: As a string, lastModified cannot easily be used for comparisions between the modified dates of documents.
public function get lastModified():DOMString
See also
dump(document.lastModified); // returns: Tuesday, July 10, 2001 10:19:42
linkColor | property |
linkColor:DOMString
Introduced in: | DOM 0 |
Deprecated since DOM Level 2 HTML
Gets/sets the color of links within the document.
Note: The color is a string representing the color as a word (e.g., "red") or hexadecimal value (e.g., "#ff0000").
The default value is "#0000FF" for IE / "#0000EE" for Mozilla
.
public function get linkColor():DOMString
public function set linkColor(value:DOMString):void
See also
DOM 1 HTML links | property |
links:HTMLCollection
[read-only] Introduced in: | DOM 1 HTML |
A collection of all AREA elements and anchor (A) elements in a document with a value for the href attribute.
public function get links():HTMLCollection
See also
var links = document.links; for(var i = 0; i < links.length; i++) { var linkHref = document.createTextNode(links[i].href); var lineBreak = document.createElement("br"); document.body.appendChild(linkHref); document.body.appendChild(lineBreak); }
DOM 0 location | property |
location:Location
[read-only] Introduced in: | DOM 0 |
Returns a Location object, which contains information about the URL of the document and provides methods for changing that URL. In Gecko browsers you can also assign to this property to load another URL.
Note: Location objects have a toString method returning the current URL. You can also assign a string to document.location. This means that you can work with document.location as if it were a string in most cases. Sometimes, for example when you need to call a String method on it, you have to explicitly call toString:
alert(document.location.toString().charAt(17))
Note: document.location was originally a read-only property, although Gecko browsers allow you to assign to it as well. For cross-browser safety, use window.location instead.
Note: To retrieve just the URL as a string, the read-only document.URL property can be used.
public function get location():Location
See also
dump(document.location); // Prints a string like // "http://www.example.com/juicybits.html" to the console
namespaces | property |
namespaces:HTMLCollection
[read-only] Non-standard (Microsoft)
Retrieves a collection of namespace objects. INCOMPLETE
public function get namespaces():HTMLCollection
See also
parentWindow | property |
parentWindow:Window
[read-only] Non-standard (Microsoft)
Gets a reference to the container object of the window.
public function get parentWindow():Window
See also
DOM 0 plugins | property |
plugins:HTMLCollection
[read-only] Introduced in: | DOM 0 |
Returns an HTMLCollection object containing one or more HTMLEmbedElements or null which represent the <embed> elements in the current document.
Note: For a list of installed plugins, use navigator.plugins instead.
public function get plugins():HTMLCollection
See also
protocol | property |
protocol:DOMString
Non-standard (Microsoft)
Sets or retrieves the protocol portion of a URL.
Note: The protocol property specifies how to transfer information from the host to the client. Windows Internet Explorer supports several predefined protocols, including http and ftp.
Note: The document, img, and location objects expose the protocol property as read-only. location.protocol property returns the initial substring of a URL, including the first colon (for example, http:). However, document.protocol returns the expanded text of the protocol acronym. For example, it returns the http protocol as Hypertext Transfer Protocol.
public function get protocol():DOMString
public function set protocol(value:DOMString):void
See also
function getProtocol() { return document.location.protocol; }
HTML 5 readyState | property |
readyState:DOMString
[read-only] Introduced in: | Non-Standard |
Modified in: | HTML 5 |
Retrieves a value that indicates the current state of the object.
State | Description |
---|---|
uninitialized | Object is not initialized with data. |
loading | Object is loading its data. |
loaded | Object has finished loading its data. |
interactive | User can interact with the object even though it is not fully loaded. |
complete | Object is completely initialized. |
Note: An object's state is initially set to uninitialized, and then to loading. When data loading is complete, the state of the link object passes through the loaded and interactive states to reach the complete state.
Note: The states through which an object passes are determined by that object; an object can skip certain states (for example, interactive) if the state does not apply to that object.
Note: Data source objects and databound elements are normally populated asynchronously, and certain programmatic operations can only be performed reliably on databound objects when they are ready for use. Therefore, the appropriate code should be written to confirm the readyState of objects prior to performing certain operations on them. For example, walking the rows of a table should not be attempted until after the table has reached the complete state.
Note: The readyState property enables the status of an object to be tested. The correct place to test the readyState property is in the event handler for onreadystatechange. Similarly, a data source object (DSO) fires the ondatasetcomplete event to notify the Web page that the dataset is ready for programmatic operation.
public function get readyState():DOMString
See also
DOM 1 HTML referrer | property |
referrer:DOMString
[read-only] Introduced in: | DOM 1 HTML |
Returns the URI of the page that linked to this page. The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark).
Note: This property returns a value only when the user reaches the current page through a link from the previous page. Otherwise, document. referrer returns an empty string; it also returns an empty string when the link is from a secure site.
Note: For example, if PageA.htm includes a link to PageB.htm, and the user clicks that link, the document.referrer on PageB.htm returns "PageA.htm." However, if the user is on PageA.htm and types PageB.htm into the address line or chooses the Open command from the File menu to get to PageB.htm, the document.referrer returns an empty string.
public function get referrer():DOMString
See also
HTML 5 scripts | property |
scripts:HTMLCollection
[read-only] Introduced in: | Non-Standard |
Modified in: | HTML 5 |
Returns an HTMLCollection object containing one or more HTMLScriptElements or null which represent the <script> elements in the current document.
public function get scripts():HTMLCollection
See also
selection | property |
selection:Selection
[read-only] Non-standard (Microsoft)
Represents the active selection, which is a highlighted block of text or other elements in the document that a user or a script can carry out some action on.
Note (IE): You can use the selection object as input from the user to identify which portion of the document to act on, or as output to the user to show the results of an action.
Note (IE): Users and scripts can create selections. Users create selections by dragging the mouse over a portion of the document. Scripts create selections by calling the select method on a text range or similar object. To get the active selection, apply the selection keyword to the document object. To carry out work on a selection, create a text range object from the selection using the createRange method.
Note: A document can have only one selection at a time. The selection has a type that determines whether it is empty or contains a block of text or elements. Although an empty selection contains nothing, you can use it to mark a position in the document.
public function get selection():Selection
See also
DOM 1 HTML title | property |
title:DOMString
Introduced in: | DOM 1 HTML |
Gets or sets the title of the document.
Note: The initial value of document.title is the text content of the <title> element.
public function get title():DOMString
public function set title(value:DOMString):void
See also
<html> <head> <title>Hello World!</title> </head> <body> <script> alert(document.title); // displays "Hello World!" document.title = "Goodbye World!"; alert(document.title); // displays "Goodbye World!" </script> </body> </html>
uniqueID | property |
uniqueID:DOMString
[read-only] Non-standard (Microsoft)
Retrieves an autogenerated, unique identifier for the object.
Note (IE): When you apply this property to the document object, the browser automatically generates a new ID that you can assign to an element's id property.
Note (IE): A new ID is generated and assigned to the element the first time the property is retrieved. Every subsequent access to the property on the same element returns the same ID.
Note (IE): The unique ID generated is not guaranteed to be the same every time the page is loaded.
public function get uniqueID():DOMString
See also
// Specifying an ID=document.uniqueID ensures that a unique identifier // will be assigned to the element being inserted into the page by // the behavior. newTextAreaID = element.document.uniqueID; element.document.body.insertAdjacentHTML ("beforeEnd", "");
DOM 1 HTML URL | property |
URL:DOMString
[read-only] Introduced in: | DOM 1 HTML |
Returns the URL of the current document.
Note: URL is a replacement for the DOM Level 0 document.location.href property. However document.URL is not settable, unlike document.location.href.
public function get URL():DOMString
See also
var currentURL = document.URL; alert(currentURL);
URLUnencoded | property |
URLUnencoded:DOMString
[read-only] Non-standard (Microsoft)
Gets the URL for the document, stripped of any character encoding.
public function get URLUnencoded():DOMString
See also
<script> function window.onload() { oURL.innerText = document.URL; oURL2.innerText = document.URLUnencoded; } </script>
vlinkColor | property |
vlinkColor:DOMString
Introduced in: | DOM 0 |
Deprecated since DOM Level 2 HTML
Gets/sets the color of links that the user has visited in the document.
Note: The color is a string representing the color as a word (e.g., "red") or hexadecimal value (e.g., "#ff0000").
The default value is "#800080" for IE / "#551A8B" for Mozilla
.
public function get vlinkColor():DOMString
public function set vlinkColor(value:DOMString):void
See also
DOM 0 width | property |
width:Number
Introduced in: | DOM 0 |
Returns the width of the body element of the current document in pixels.
Note: Not supported by IE.
public function get width():Number
public function set width(value:Number):void
See also
function init() { alert("The width of the document is " + document.width + " pixels."); }
XSLDocument | property |
XSLDocument:DOMObject
[read-only] Non-standard (Microsoft)
Retrieves a reference to the top-level node of the Extensible Stylesheet Language (XSL) document.
Note (IE): You can use the XSLDocument property to access the Document Object Model (DOM) for the XSL style sheet. For more information, refer to the XML DOM overview.
public function get XSLDocument():DOMObject
See also
function sort(key) { // Find the "order-by" attributes in the style sheet. var s = document.XSLDocument.selectNodes("*/xsl:template[&64;match='menu'] //xsl:apply-templates/&64;order-by"); // Replace the values with the new sort key. for (var i = s.nextNode(); i != null; i = s.nextNode()) { i.value = key; } // Find the subset of the document we need to update. var d = document.XMLDocument.selectSingleNode("story/menu"); // Apply the style sheet to the subset, and update the display. menu.innerHTML = d.transformNode(document.XSLDocument); }
Non-Standard Obsolete captureEvents | () | method |
public function captureEvents(eventTypeList:DOMString):void
Non-standard (Mozilla)
Obsolete
Instructs the browser to grab events of a specific type before they reach their intended target document objects. The object invoking this method must then have event handlers defined for the given event types to process the event.
Parameters
eventTypeList:DOMString — A comma-separated list of case-sensitive event types as derived from the available
Event object constants, such as Event.CLICK or Event.MOUSEMOVE.
|
See also
clear | () | method |
public function clear():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 |
Introduced in: | DOM 0 |
Deprecated
This method used to clear the whole specified document in early (pre-1.0) versions of Mozilla.
In recent versions of Mozilla-based applications as well as in Internet Explorer and Netscape 4 this method does nothing.
See also
DOM 1 HTML close | () | method |
public function close():void
Introduced in: | DOM 1 HTML |
Closes a document stream opened by open() and forces rendering.
See also
// open a document to write to it. // write the content of the document. // close the document. document.open(); document.write("<p>The one and only content.</p>"); document.close();
DOM 3 XPath createExpression | () | method |
public function createExpression(expression:DOMString, resolver:XPathNSResolver):XPathExpression
Introduced in: | DOM 3 XPath |
Creates a parsed XPath expression with resolved namespaces. This is useful when an expression will be reused in an application since it makes it possible to compile the expression string into a more efficient internal form and preresolve all namespace prefixes which occur within the expression.
Note (Mozilla): Prior to Firefox 3, you could call this method on documents other than the one you planned to run the XPath against. Under Firefox 3, you must call it on the same document.
Parameters
expression:DOMString — The XPath expression string to be parsed.
| |
resolver:XPathNSResolver — The resolver permits translation of all prefixes, including the xml
namespace prefix, within the XPath expression into appropriate namespace URIs. If this
is specified as null, any namespace prefix within the expression will result in
DOMException being thrown with the code NAMESPACE_ERR.
|
XPathExpression — The compiled form of the XPath expression.
|
See also
DOM 3 XPath createNSResolver | () | method |
public function createNSResolver(nodeResolver:Node):XPathNSResolver
Introduced in: | DOM 3 XPath |
Adapts any DOM node to resolve namespaces so that an XPath expression can be easily evaluated relative to the context of the node where it appeared within the document. This adapter works like the DOM Level 3 method lookupNamespaceURI on nodes in resolving the namespaceURI from a given prefix using the current information available in the node's hierarchy at the time lookupNamespaceURI is called. also correctly resolving the implicit xml prefix.
Note: XPath defines QNames without prefix to match only elements in the
null namespace. There is no way in XPath to pick up the default namespace as applied to a regular
element reference (e.g., p[&64;id='_myid']
for xmlns='http://www.w3.org/1999/xhtml'
).
To match default elements in a non-null namespace, you either have to refer to a particular element using
a form such as *
Parameters
nodeResolver:Node — The node to be used as a context for namespace resolution.
|
XPathNSResolver — XPathNSResolver which resolves namespaces with respect to the definitions in scope for a specified node.
|
See also
DOM 3 XPath evaluate | () | method |
public function evaluate(expression:DOMString, contextNode:Node, resolver:XPathNSResolver, type:Number, result:DOMObject):DOMObject
Introduced in: | DOM 3 XPath |
Evaluates an XPath expression string and returns a result of the specified type if possible.
Parameters
expression:DOMString — The XPath expression string to be parsed and evaluated.
| |
contextNode:Node — The context is context node for the evaluation of this XPath expression.
If the XPathEvaluator was obtained by casting the Document then this must be owned by the same
document and must be a Document, Element, Attribute, Text, CDATASection, Comment,
ProcessingInstruction, or XPathNamespace node. If the context node is a Text or a CDATASection,
then the context is interpreted as the whole logical text node as seen by XPath, unless the node
is empty in which case it may not serve as the XPath context.
| |
resolver:XPathNSResolver — The resolver permits translation of all prefixes, including the xml namespace
prefix, within the XPath expression into appropriate namespace URIs. If this is specified as null,
any namespace prefix within the expression will result in DOMException being thrown with the
code NAMESPACE_ERR.
| |
type:Number — If a specific type is specified, then the result will be returned as the
corresponding type. For XPath 1.0 results, this must be one of the codes of the XPathResult interface.
| |
result:DOMObject — The result specifies a specific result object which may be reused and returned by
this method. If this is specified as nullor the implementation does not reuse the specified result,
a new result object will be constructed and returned. For XPath 1.0 results, this object will be
of type XPathResult.
|
DOMObject — The result of the evaluation of the XPath expression. For XPath 1.0 results, this object
will be of type XPathResult.
|
See also
var headings = document.evaluate("//h2", document, null, XPathResult.ANY_TYPE, null); /* Search the document for all h2 elements. * The result will likely be an unordered node iterator. */ var thisHeading = headings.iterateNext(); var alertText = "Level 2 headings in this document are:\n"; while (thisHeading) { alertText += thisHeading.textContent + "\n"; thisHeading = headings.iterateNext(); } alert(alertText); // Alerts the text of all h2 elements
execCommand | () | method |
public function execCommand(aCommandName:DOMString, aShowDefaultUI:Boolean, aValueArgument:DOMString):Boolean
Non-standard (Microsoft/Mozilla)
When an HTML document has been switched to designMode, the document object exposes the execCommand method which allows one to run commands to manipulate the contents of the editable region. Most commands affect the document's selection (bold, italics, etc), while others insert new elements (adding a link) or affect an entire line (indenting). When using contentEditable, calling execCommand will affect the currently active editable element.
Parameters
aCommandName:DOMString — The name of the command
| |
aShowDefaultUI:Boolean — Whether the default user interface should be shown. This is not implemented in Mozilla.
| |
aValueArgument:DOMString — Some commands (such as insertimage) require an extra value argument (the image's url).
Pass an argument of null if no argument is needed.
|
Boolean — True if successful, or an error value otherwise.
|
See also
//HTML: <button onclick="doRichEditCommand('bold')" style="font-weight:bold;">B</button> //JavaScript: function doRichEditCommand(aName, aArg){ getIFrameDocument('editorWindow').execCommand(aName,false, aArg); document.getElementById('editorWindow').contentWindow.focus() }
execCommandShowHelp | () | method |
public function execCommandShowHelp(aCommandName:DOMString):Boolean
Non-standard (Microsoft/Mozilla)
Displays help information for the given command identifier.
Parameters
aCommandName:DOMString — Contains an identifier of a command. It can be any command identifier given in the list of Command Identifiers.
|
Boolean — True if successful, or an error value otherwise.
|
See also
fireEvent | () | method |
public function fireEvent(type:DOMString, event:Object = null):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)
Fires a specified event on the object.
If the event being fired cannot be cancelled, fireEvent always returns true.
Regardless of their values specified in the event object, the values of the four event properties—cancelBubble, returnValue, srcElement, and type—are automatically initialized to the values shown in the following table.
Parameters
type:DOMString — String that specifies the name of the event to fire.
| |
event:Object (default = null ) — Object that specifies the event object from which to obtain event object properties.
|
Boolean — Event fired successfully
|
See also
focus | () | method |
public function focus():void
Non-standard (Microsoft)
Causes the element to receive the focus and executes the code specified by the onfocus event.
Note (IE): This method raises the onfocus event. The effect depends on the object calling the method. When called for child windows (such as those created with the open method of a window object), focus brings the target window to the foreground.
Note (IE): Windows Internet Explorer 8 and later. The focus method no longer brings child windows (such as those created with the open method) to the foreground. Child windows now request focus from the user, usually by flashing the title bar. To directly bring the window to the foreground, add script to the child window that calls the focus method of its window object.
Note: Internet Explorer 7 and later. For security reasons, child windows will only respond to the focus method when the following conditions are true:
Note: As of Microsoft Internet Explorer 5, elements that expose the focus method must have the TABINDEX attribute set.
Note: Elements cannot receive focus until the document finishes loading.
See also
getBoxObjectFor | () | method |
public function getBoxObjectFor(element:Element):nsIBoxObject
Non-standard (Mozilla)
This particular method was a way for XUL elements to efficiently determine their position, amongst other things. A couple of years ago this feature started to be used by the general web-developer world. This was quickly realized to be a major mistake.
Parameters
element:Element — Target element
|
nsIBoxObject — The dimensions of the element
|
See also
HTML 5 getElementsByClassName | () | method |
public function getElementsByClassName(classNames:DOMString):NodeList
Introduced in: | HTML 5 |
Returns a set of elements with the given class name. When called on the document object, the complete document is searched, including the root node. You may also call getElementsByClassName on any element; it will return only elements under the specified root element with the given class name.
Parameters
classNames:DOMString — An unordered set of unique space-separated tokens representing classes.
|
NodeList — A live NodeList object containing all the elements in the document, in tree order, that have
all the classes specified in that argument, having obtained the classes by splitting a string on spaces.
If there are no tokens specified in the argument, then returns an empty NodeList.
|
See also
Get all elements that have a class of 'test'
document.getElementsByClassName('test')
Get all elements that have a class of 'red' and 'test'
document.getElementsByClassName('red test')
Get all elements that have a class of 'test', inside of an element that has the ID of 'main'
document.getElementById('main').getElementsByClassName('test')
And if we go ahead and add in JavaScript 1.6's Array extras, we can do some really-cool matches.
Find all div elements that have a class of 'test'
Array.filter( document.getElementsByClassName('test'), function(elem) { return elem.nodeName == 'DIV'; });
Find all elements that have a class of 'test' (as do their parent element)
var test = document.getElementsByClassName('test'); Array.filter( test, function(elem){ return Array.indexOf( test, elem.parentNode ) > -1; });
DOM 1 HTML getElementsByName | () | method |
public function getElementsByName(elementName:DOMString):NodeList
Introduced in: | DOM 1 HTML |
Returns a list of elements with a given name in the (X)HTML document.
Parameters
elementName:DOMString — The name attribute value for an element.
|
NodeList — The matching elements.
|
See also
// return some of the forms //<form name="up"><input type="text"/></form> //<form name="up"><input type="text"/></form> //<form name="down"><input type="text"/></div> //<form name="down"><input type="text"/></div> up_forms = document.getElementsByName("up"); dump(up_forms.item(0).tagName); // returns "div"
DOM 0 getSelection | () | method |
public function getSelection():DOMString
Introduced in: | DOM 0 |
Return the contents of selected text in the current document.
ReturnsDOMString — The selected text
|
See also
<INPUT TYPE="BUTTON" NAME="selectString" VALUE="Show any highlighted text" onClick="alert('The following text is selected:\n'+document.getSelection());">
HTML 5 hasFocus | () | method |
public function hasFocus():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 |
Introduced in: | HTML 5 |
The hasFocus method returns true if the focus is currently located anywhere inside the specified document.
ReturnsBoolean — Returns true if the document has focus; otherwise, returns false.
|
See also
DOM 1 HTML open | () | method |
public function open(url:DOMString, name:DOMString, features:DOMString, replace:Boolean):*
Introduced in: | DOM 1 HTML |
Open a document stream for writing. If a document exists in the target, this method clears it.
Note (IE): All params are for IE only
Note: This method and the ones following allow a user to add to or replace the structure model of a document using strings of unparsed HTML. At the time of writing alternate methods for providing similar functionality for both HTML and XML documents were being considered.
Note (Mozilla): Also, an automatic document.open() call happens when document.write() is called after the page has loaded, but that's not defined in the W3C specification.
IE Style
Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the
url
parameter and the name
parameter to collect the output of the write method and the writeln method.
Parameters
url:DOMString — When a new document is opened, url is a String that specifies a MIME type for the document.
When a new window is opened, url is a String that specifies the URL to render in the new window. If a url
is not specified, a new window with about:blank is displayed.
| |||||||||||||||||||||||||||||||
name:DOMString — Optional. When a new document is opened, specify the String replace for name to specify
that the new document replaces the current document in the history list. If the replace value is not specified
when you open a document, a new entry is added to the history list. When a window is opened, this is a String
that specifies the name of the window. The value of this parameter can be specified as the value of the TARGET
attribute for a form or an a element. This value defines this new window as the location to load a document.
| |||||||||||||||||||||||||||||||
features:DOMString — Optional. A list of comma-separated items. Each item consists of an option and a value, separated
by an equals sign (=), for example, "fullscreen=yes, toolbar=yes". The following features are supported.
| |||||||||||||||||||||||||||||||
replace:Boolean — Optional. When the url is loaded into the same window, this Boolean parameter specifies whether the url creates a new entry or replaces the current entry in the window's history list.
|
* — Returns a reference to the new document object or the window object. Use this reference to access properties and methods of the new document or window.
|
See also
// In this example, the document contents are // overwritten as the document // is reinitialized on open(). document.write("<html><p>remove me</p></html>"); document.open(); // document is empty.
IE Style
The following example shows how to use the open method to replace the current document with a new document and display the HTML markup contained in the variable sMarkup.
<html> <head> <title>First Document</title> <script> function replace(){ var oNewDoc = document.open("text/html", "replace"); var sMarkup = "<html><head><title>New Document</title></head><body>Hello, world</body></html>"; oNewDoc.write(sMarkup); oNewDoc.close(); } </script> </head> <body> <h1>I just want to say</h1><br> <!--Button will call the replace function and replace the current page with a new one--> <input type ="button" value = "Finish Sentence" onclick="replace();"> </body> </html>
queryCommandEnabled | () | method |
public function queryCommandEnabled(cmdId:DOMString):Boolean
Non-standard (Microsoft/Mozilla)
Determines whether the given command can be executed on the document in its current state.
Note (IE): Using queryCommandEnabled ("delete") on a TextRange object returns true, while queryCommandEnabled ("delete") on a document object returns false. However, execCommand ("delete") can still be used to delete the selected text.
Parameters
cmdId:DOMString — Specifies a command identifier.
|
Boolean — True if successful, or an error value otherwise.
|
See also
queryCommandIndeterm | () | method |
public function queryCommandIndeterm(cmdId:DOMString):Boolean
Non-standard (Microsoft/Mozilla)
Determines whether the current selection is in an indetermined state.
Parameters
cmdId:DOMString — Specifies a command identifier.
|
Boolean — True if successful, or an error value otherwise.
|
See also
queryCommandState | () | method |
public function queryCommandState(cmdId:DOMString):Boolean
Non-standard (Microsoft/Mozilla)
Determines whether the given command has been executed on the current selection.
Parameters
cmdId:DOMString — Specifies a command identifier.
|
Boolean — True if the command has been completed; false if the command has not completed; null if the state cannot be accurately determined.
|
See also
queryCommandSupported | () | method |
public function queryCommandSupported(cmdId:DOMString):Boolean
Non-standard (Microsoft/Mozilla)
Returns a Boolean value that indicates whether the current command is supported on the current range.
Parameters
cmdId:DOMString — Specifies a command identifier.
|
Boolean — True if successful, or an error value otherwise.
|
See also
queryCommandText | () | method |
public function queryCommandText(cmdId:DOMString):DOMString
Non-standard (Microsoft/Mozilla)
Retrieves the string associated with a command.
Parameters
cmdId:DOMString — Specifies a command identifier.
|
DOMString — The text associated with the command will be stored.
|
See also
queryCommandValue | () | method |
public function queryCommandValue(cmdId:DOMString):*
Non-standard (Microsoft/Mozilla)
Determines the current value of the document, range, or current selection for the given command.
Parameters
cmdId:DOMString — Specifies a command identifier.
|
* — True if successful, or an error value otherwise.
|
See also
recalc | () | method |
public function recalc(forceAll:Boolean):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)
Recalculates all dynamic properties in the current document.
Note: Implicit dependencies, internal property changes, and related properties can cause some expressions not to recalculate, even though the referenced properties might have changed. For example, resizing the main window changes the clientWidth property. Expressions that reference clientWidth might not be recalculated, because the change might not be recognized.
Note: Implicit dependencies refer to properties that can be modified by changes in other properties. For example, the height property of a div object implicitly depends on the innerHTML property of the div object. However, if an expression references the height property, a change in the innerHTML property, which might modify the height, does not cause a recalculation of the expression on a subsequent call to recalc.
Note: Related properties can access or manipulate data or behaviors through one or more other properties. For example, pixelLeft and posLeft can set or get the left position of the element. However, if an expression that references pixelLeft and posLeft is modified, the expression might not be recalculated on subsequent calls to recalc.
Note: Related properties that can cause this behavior include the following: clientHeight, clientLeft, clientTop, clientWidth, height, left, offsetHeight, offsetLeft, offsetTop, offsetWidth, pixelHeight, pixelLeft, pixelTop, pixelWidth, posHeight, posLeft, posTop, posWidth, and top.
Note: To force the recalculation of all expressions, refer to the same property name or manually call recalc(true).
Parameters
forceAll:Boolean — Optional. A Boolean that specifies one of the following values.
|
See also
<HTML> <HEAD> <TITLE>Recalc Example</TITLE> <STYLE> BUTTON {font-size:14;width:150} </STYLE> <SCRIPT> var timerID = null; var seconds = 0; // // This function is called when the page loads. // It sets up a couple of expressions. // function init() { A.style.setExpression("width","seconds0"); B.setExpression("innerText","seconds.toString()"); } // // This function gets calls once a second and updates the seconds // variable. Notice that without recalc, the expressions aren't // updated until the mouse is moved. // function timer() { seconds++; document.recalc(); } // // starts the timer // function starttimer() { if (timerID == null) { timerID = setInterval("timer()", 1000); startButton.disabled = true; stopButton.disabled = false; } } // // stops the timer // function stoptimer() { if (timerID != null) { clearInterval(timerID); timerID = null; startButton.disabled = false; stopButton.disabled = true; } } // // resets the timer // function resettimer() { seconds = 0; } </SCRIPT> </HEAD> <BODY onload="init()"> <DIV id=A style="background-color:lightblue" ></DIV> <DIV id=B style="color:hotpink;font-weight:bold"></DIV> <BR> <BUTTON id="startButton" onclick="starttimer()">Start the Timer</BUTTON></BR> <BUTTON id="stopButton" DISABLED="true" onclick="stoptimer()">Stop the Timer</BUTTON><BR> <BUTTON id="resetButton" onclick="resettimer()">Reset the Timer</BUTTON><BR> <P style="width:320;color:peru;background-color:wheat"> This example illustrates the use of document.recalc(). If the calls to recalc are omitted in this example, expressions will not be updated until the mouse is moved. </P> </BODY> </HTML>
releaseCapture | () | method |
public function releaseCapture():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)
Removes mouse capture from the object in the current document.
For releaseCapture to have an effect, you must set mouse capture through the setCapture method.
You can invoke the releaseCapture method on the document object. The releaseCapture method makes it unnecessary to determine which element has capture to programmatically release it. Other actions that release document capture include displaying a modal dialog box and switching focus to another application or browser window.
See also
<BODY onload="oOwnCapture.setCapture();" onclick="document.releaseCapture();"> <DIV ID=oOwnCapture onmousemove="oWriteLocation.value = event.clientX + event.clientY"; onlosecapture="alert(event.srcElement.id + ' has lost mouse capture.')"> <TEXTAREA ID=oWriteLocation COLS=2></TEXTAREA> </DIV> <HR> <DIV ID=oNoCapture> <P>Click the document to invoke the releaseCapture method.</P> </DIV> </BODY>
Non-Standard Obsolete releaseEvents | () | method |
public function releaseEvents(eventTypeList:DOMString):void
Non-standard (Mozilla)
Obsolete
The opposite of document.captureEvents( ), this method turns off event capture at the document level for one or more specific events named in the parameter list.
Parameters
eventTypeList:DOMString — A comma-separated list of case-sensitive event types as derived from the available
Event object constants, such as Event.CLICK or Event.MOUSEMOVE.
|
See also
removeNode | () | method |
public function removeNode(removeChildren:Boolean = false):Node
Non-standard (Microsoft)
Removes the object from the document hierarchy.
This property is accessible at run time. If elements are removed at run time, before the closing tag is parsed, areas of the document might not render.
Parameters
removeChildren:Boolean (default = false ) — If the childNodes collection of the object is removed
|
Node — Returns a reference to the object that is removed.
|
See also
replaceNode | () | method |
public function replaceNode(newNode:Node):Node
Non-standard (Microsoft)
Replaces the object with another element.
When a node is replaced, all values that are associated with the replaced object are removed. For example, if a b object is replaced with an i object, any attributes and text between the opening and closing tags are also replaced. To preserve these values, copy them to the new element before the original object is replaced.
This method is accessible at run time. If elements are removed at run time before the closing tag is parsed, areas of the document might not render.
Parameters
newNode:Node — Specifies the new element to replace the object.
|
Node — Returns a reference to the object that is replaced.
|
See also
<SCRIPT> function fnReplace() { var sPreserve = oList.innerHTML; var oNewNode = document.createElement("OL"); oList.replaceNode(oNewNode); oNewNode.innerHTML = sPreserve; } </SCRIPT> <UL ID = oList> <LI>List Item 1 <LI>List Item 2 <LI>List Item 3 <LI>List Item 4 </UL> <INPUT TYPE = button VALUE = "Replace List" onclick = "fnReplace()">
Non-Standard Obsolete routeEvent | () | method |
public function routeEvent(event:Event):void
Non-standard (Mozilla)
Obsolete
Used inside an event handler function, this method lets the event pass to its intended target object.
Parameters
event:Event |
See also
swapNode | () | method |
public function swapNode(node:Node):Node
Non-standard (Microsoft)
Exchanges the location of two objects in the document hierarchy.
This method is accessible at run time. If elements are removed at run time, before the closing tag is parsed, areas of the document might not render.
Parameters
node:Node — Specifies the existing element.
|
Node — Returns a reference to the object that invoked the method.
|
See also
<script> function fnSwap() { oList.children(0).swapNode(oList.children(1)); } </script> <ul ID = oList> <li>List Item 1</li> <li>List Item 2</li> <li>List Item 3</li> <li>List Item 4</li> </ul> <input type=button value="Swap List" onclick="fnSwap()">
DOM 1 HTML write | () | method |
public function write(text:DOMString):void
Introduced in: | DOM 1 HTML |
Write a string of text to a document stream opened by open(). Note that the function will produce a document which is not necessarily driven by a DTD and therefore might be produce an invalid result in the context of the document.
Note (Mozilla): Writing to a document that has already loaded without calling document.open() will automatically perform a document.open call. Once you have finished writing, it is recommended to call document.close(), to tell the browser to finish loading the page. The text you write is parsed into the document's structure model. In the example above, the h1 element becomes a node in the document.
Note (Mozilla): If the document.write() call is embedded directly in the HTML code, then it will not call document.open(). For example:
<div> <script type="text/javascript"> document.write("<h1>Main title</h1>") </script> </div>
Parameters
text:DOMString — The string to be parsed into some structure in the
document structure model.
|
See also
<html> <head> <title>write example</title> <script type="text/javascript"> function newContent() { alert("load new content"); document.open(); document.write("<h1>Out with the old - in with the new!</h1>"); document.close(); } </script> </head> <body onload="newContent();"> <p>Some original document content.</p> </body> </html>
DOM 1 HTML writeln | () | method |
public function writeln(text:DOMString):void
Introduced in: | DOM 1 HTML |
Write a string of text followed by a newline character to a document stream opened by open(). Note that the function will produce a document which is not necessarily driven by a DTD and therefore might be produce an invalid result in the context of the document.
Note: document.writeln is the same as document.write but adds a newline.
Parameters
text:DOMString — The string to be parsed into some structure in the
document structure model.
|
See also
document.writeln("<p>enter password:</p>");