Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply.
This specification defines the Document Object Model Level 2, a platform- and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure and style of documents. The Document Object Model Level 2 builds on the Document Object Model Level 1.
The DOM Level 2 is made of a set of core interfaces to create and manipulate the structure and contents of a document and a set of optional modules. These modules contain specialized interfaces dedicated to XML, HTML, an abstract view, generic stylesheets, Cascading Style Sheets, Events, traversing the document structure, and a Range object.
This specification is still in the Candidate Recommendation phase. This means the specification is stable, and the period to allow implementation of the specification is extended. The new Candidate Recommendation period ends the 20 March 2000.
Comments on this document are invited and are to be sent to the public mailing list www-dom@w3.org. An archive is available at http://lists.w3.org/Archives/Public/www-dom/.
Should this specification prove impossible or very difficult to implement, the necessary changes to make it implementable will be made. If this specification is possible to implement, the only changes which will be made to this specification are minor editorial changes and clarifications.
This document has been produced as part of the W3C DOM Activity. The authors of this document are the DOM WG members. Different modules of the Document Object Model have different editors.
A list of current W3C Recommendations and other technical documents can be found at http://www.w3.org/TR.
Copyright © 2000 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved.
This document is published under the W3C Document Copyright Notice and License. The bindings within this document are published under the W3C Software Copyright Notice and License. The software license requires "Notice of any changes or modifications to the W3C files, including the date changes were made." Consequently, modified versions of the DOM bindings must document that they do not conform to the W3C standard; in the case of the IDL binding, the pragma prefix can no longer be 'w3c.org'; in the case of the Java binding, the package names can no longer be in the 'org.w3c' package.
Note: This section is a copy of the W3C Document Notice and License and could found be at http://www.w3.org/Consortium/Legal/copyright-documents-19990405.
Copyright © 1994-2000 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved.
http://www.w3.org/Consortium/Legal/
Public documents on the W3C site are provided by the copyright holders under the following license. The software or Document Type Definitions (DTDs) associated with W3C specifications are governed by the Software Notice. By using and/or copying this document, or the W3C document from which this statement is linked, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions:
Permission to use, copy, and distribute the contents of this document, or the W3C document from which this statement is linked, in any medium for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the document, or portions thereof, that you use:
When space permits, inclusion of the full text of this NOTICE should be provided. We request that authorship attribution be provided in any software, documents, or other items or products that you create pursuant to the implementation of the contents of this document, or any portion thereof.
No right to create modifications or derivatives of W3C documents is granted pursuant to this license. However, if additional requirements (documented in the Copyright FAQ) are satisfied, the right to create modifications or derivatives is sometimes granted by the W3C to individuals complying with those requirements.
THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to this document or its contents without specific, written prior permission. Title to copyright in this document will at all times remain with copyright holders.
Note: This section is a copy of the W3C Software Copyright Notice and License and could be found at http://www.w3.org/Consortium/Legal/copyright-software-19980720
Copyright © 1994-2000 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved.
http://www.w3.org/Consortium/Legal/
This W3C work (including software, documents, or other related items) is being provided by the copyright holders under the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions:
Permission to use, copy, and modify this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications, that you make:
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
The Document Object Model (DOM) is an application programming interface (API) for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated. In the DOM specification, the term "document" is used in the broad sense - increasingly, XML is being used as a way of representing many different kinds of information that may be stored in diverse systems, and much of this would traditionally be seen as data rather than as documents. Nevertheless, XML presents this data as documents, and the DOM may be used to manage this data.
With the Document Object Model, programmers can build documents, navigate their structure, and add, modify, or delete elements and content. Anything found in an HTML or XML document can be accessed, changed, deleted, or added using the Document Object Model, with a few exceptions - in particular, the DOM interfaces for the XML internal and external subsets have not yet been specified.
As a W3C specification, one important objective for the Document Object Model is to provide a standard programming interface that can be used in a wide variety of environments and applications. The DOM is designed to be used with any programming language. In order to provide a precise, language-independent specification of the DOM interfaces, we have chosen to define the specifications in Object Management Group (OMG) IDL, as defined in the CORBA 2.2 specification [CORBA]. In addition to the OMG IDL specification, we provide language bindings for Java and ECMAScript (an industry-standard scripting language based on JavaScript and JScript) [Java] [ECMAScript].
Note: OMG IDL is used only as a language-independent and implementation-neutral way to specify interfaces. Various other IDLs could have been used. In general, IDLs are designed for specific computing environments. The Document Object Model can be implemented in any computing environment, and does not require the object binding runtimes generally associated with such IDLs.
The DOM is a programming API for documents. It is based on an object structure that closely resembles the structure of the documents it models. For instance, consider this table, taken from an HTML document:
<TABLE> <TBODY> <TR> <TD>Shady Grove</TD> <TD>Aeolian</TD> </TR> <TR> <TD>Over the River, Charlie</TD> <TD>Dorian</TD> </TR> </TBODY> </TABLE>
The DOM represents this table like this:
In the DOM, documents have a logical structure which is very much like a tree; to be more precise, which is like a "forest" or "grove", which can contain more than one tree. Each document contains zero or one doctype nodes, one root element node, and zero or more comments or processing instructions; the root element serves as the root of the element tree for the document. However, the DOM does not specify that documents must be implemented as a tree or a grove, nor does it specify how the relationships among objects be implemented. The DOM is a logical model that may be implemented in any convenient manner. In this specification, we use the term structure model to describe the tree-like representation of a document. We also use the term "tree" when referring to the arrangement of those information items which can be reached by using "tree-walking" methods; (this does not include attributes). One important property of DOM structure models is structural isomorphism: if any two Document Object Model implementations are used to create a representation of the same document, they will create the same structure model, in accordance with the XML Information Set [Infoset].
Note: There may be some variations depending on the parser being used to build the DOM. For instance, the DOM may not contain whitespaces in element content if the parser discards them.
The name "Document Object Model" was chosen because it is an "object model" in the traditional object oriented design sense: documents are modeled using objects, and the model encompasses not only the structure of a document, but also the behavior of a document and the objects of which it is composed. In other words, the nodes in the above diagram do not represent a data structure, they represent objects, which have functions and identity. As an object model, the DOM identifies:
The structure of SGML documents has traditionally been represented by an abstract data model, not by an object model. In an abstract data model, the model is centered around the data. In object oriented programming languages, the data itself is encapsulated in objects that hide the data, protecting it from direct external manipulation. The functions associated with these objects determine how the objects may be manipulated, and they are part of the object model.
This section is designed to give a more precise understanding of the DOM by distinguishing it from other systems that may seem to be like it.
The DOM originated as a specification to allow JavaScript scripts and Java programs to be portable among Web browsers. "Dynamic HTML" was the immediate ancestor of the Document Object Model, and it was originally thought of largely in terms of browsers. However, when the DOM Working Group was formed at W3C, it was also joined by vendors in other domains, including HTML or XML editors and document repositories. Several of these vendors had worked with SGML before XML was developed; as a result, the DOM has been influenced by SGML Groves and the HyTime standard. Some of these vendors had also developed their own object models for documents in order to provide an API for SGML/XML editors or document repositories, and these object models have also influenced the DOM.
In the fundamental DOM interfaces, there are no objects representing entities. Numeric character references, and references to the pre-defined entities in HTML and XML, are replaced by the single character that makes up the entity's replacement. For example, in:
<p>This is a dog & a cat</p>
the "&" will be replaced by the character "&", and the text in the P element will form a single continuous sequence of characters. Since numeric character references and pre-defined entities are not recognized as such in CDATA sections, or in the SCRIPT and STYLE elements in HTML, they are not replaced by the single character they appear to refer to. If the example above were enclosed in a CDATA section, the "&" would not be replaced by "&"; neither would the <p> be recognized as a start tag. The representation of general entities, both internal and external, are defined within the extended (XML) interfaces of DOM Level 1 [DOM-Level-1].
Note: When a DOM representation of a document is serialized as XML or HTML text, applications will need to check each character in text data to see if it needs to be escaped using a numeric or pre-defined entity. Failing to do so could result in invalid HTML or XML. Also, implementations should be aware of the fact that serialization into a character encoding ("charset") that does not fully cover ISO 10646 may fail if there are characters in markup or CDATA sections that are not present in the encoding.
The Document Object Model level 2 consists of several modules: Core, HTML, Views, StyleSheets, CSS, Events, Traversal, and Range. The DOM Core represents the functionality used for XML documents, and also serves as the basis for DOM HTML.
A compliant implementation of the DOM must implement all of the fundamental interfaces in the Core chapter with the semantics as defined. Further, it must implement at least one of the HTML DOM and the extended (XML) interfaces with the semantics as defined. The other modules are optional.
A DOM application can use the hasFeature
method of the
DOMImplementation
interface to determine whether the module
is supported or not. The feature strings for all modules in DOM Level 2
are listed in the following table; (strings are case-insensitive):
Module | Feature String |
---|---|
XML | XML |
HTML | HTML |
Views | Views |
StyleSheets | StyleSheets |
CSS | CSS |
CSS (extended interfaces) | CSS2 |
Events | Events |
User Interface Events (UIEvent interface) | UIEvents |
Mouse Events (MouseEvents interface) | MouseEvents |
Mutation Events (MutationEvent interface) | MutationEvents |
HTML Events | HTMLEvents |
Traversal | Traversal |
Range | Range |
The following table contains all dependencies between modules:
Module | Implies |
---|---|
Views | XML or HTML |
StyleSheets | StyleSheets and XML or HTML |
CSS | StyleSheets, Views and XML or HTML |
CSS2 | CSS, StyleSheets, Views and XML or HTML |
Events | XML or HTML |
UIEvents | Views, Events and XML or HTML |
MouseEvents | UIEvents, Views, Events and XML or HTML |
MutationEvents | Events and XML or HTML |
HTMLEvents | Events and XML or HTML |
The DOM specifies interfaces which may be used to manage XML or HTML documents. It is important to realize that these interfaces are an abstraction - much like "abstract base classes" in C++, they are a means of specifying a way to access and manipulate an application's internal representation of a document. Interfaces do not imply a particular concrete implementation. Each DOM application is free to maintain documents in any convenient representation, as long as the interfaces shown in this specification are supported. Some DOM implementations will be existing programs that use the DOM interfaces to access software written long before the DOM specification existed. Therefore, the DOM is designed to avoid implementation dependencies; in particular,
The Level 1 interfaces were extended to provide both Level 1 and Level 2 functionality.
DOM implementations in languages other than Java or ECMA Script may choose bindings that are appropriate and natural for their language and run time environment. For example, some systems may need to create a Document2 class which inherits from Document and contains the new methods and attributes.
This section defines a set of objects and
interfaces for accessing and manipulating document objects.
The functionality specified in this section (the
Core functionality) is sufficient to allow
software developers and web script authors to access and
manipulate parsed HTML and XML content inside conforming
products. The DOM Core API also allows creation and population
of a Document
object using only DOM API calls; loading
a Document
and saving it persistently is left
to the product that implements the DOM API.
The DOM presents documents as a hierarchy of Node
objects that also implement other, more specialized interfaces. Some
types of nodes may have child nodes of various types, and others are
leaf nodes that cannot have anything below them in the document
structure. For XML and HTML, the node types, and which node types they
may have as children, are as follows:
Document
-- Element
(maximum of
one), ProcessingInstruction
, Comment
,
DocumentType
(maximum of one) DocumentFragment
-- Element
,
ProcessingInstruction
, Comment
,
Text
, CDATASection
,
EntityReference
DocumentType
-- no childrenEntityReference
-- Element
,
ProcessingInstruction
, Comment
,
Text
, CDATASection
,
EntityReference
Element
-- Element
,
Text
, Comment
,
ProcessingInstruction
, CDATASection
,
EntityReference
Attr
-- Text
,
EntityReference
ProcessingInstruction
-- no childrenComment
-- no childrenText
-- no childrenCDATASection
-- no childrenEntity
-- Element
,
ProcessingInstruction
, Comment
,
Text
, CDATASection
,
EntityReference
Notation
-- no childrenThe DOM also specifies a NodeList
interface to handle
ordered lists of Nodes
, such as the children of a
Node
, or the elements returned by the
getElementsByTagName
method of the Element
interface, and also a NamedNodeMap
interface to handle
unordered sets of nodes referenced by their name attribute, such as the
attributes of an Element
. NodeList
and NamedNodeMap
objects in the DOM are live; that is,
changes to the underlying document structure are reflected in all
relevant NodeList
and NamedNodeMap
objects.
For example, if a DOM user gets a NodeList
object
containing the children of an Element
, then subsequently
adds more children to that element (or removes children, or modifies
them), those changes are automatically reflected in the
NodeList
, without further action on the user's
part. Likewise, changes to a Node
in the tree are
reflected in all references to that Node
in
NodeList
and NamedNodeMap
objects.
Finally, the interfaces Text
, Comment
, and
CDATASection
all inherit from the
CharacterData
interface.
Most of the APIs defined by this specification are
interfaces rather than classes. That means that
an implementation need only expose methods with
the defined names and specified operation, not
implement classes that correspond directly to the interfaces.
This allows the DOM APIs to be implemented as a thin veneer on top
of legacy applications with their own data structures, or
on top of newer applications with different class hierarchies.
This also means that ordinary constructors (in the Java or C++
sense) cannot be used to create DOM objects, since the
underlying objects to be constructed may have little relationship
to the DOM interfaces. The conventional solution to this in
object-oriented design is to define factory methods
that create instances of objects that implement the various
interfaces. Objects implementing some
interface "X" are created by a "createX()" method on the
Document
interface; this is because all DOM objects live
in the context of a specific Document.
The DOM Level 2 API does not define a standard
way to create DOMImplementation
objects; DOM
implementations must provide some proprietary way of bootstrapping
these DOM interfaces, and then all other objects can be built from
there.
The Core DOM APIs are designed to be compatible with a wide range of languages, including both general-user scripting languages and the more challenging languages used mostly by professional programmers. Thus, the DOM APIs need to operate across a variety of memory management philosophies, from language bindings that do not expose memory management to the user at all, through those (notably Java) that provide explicit constructors but provide an automatic garbage collection mechanism to automatically reclaim unused memory, to those (especially C/C++) that generally require the programmer to explicitly allocate object memory, track where it is used, and explicitly free it for re-use. To ensure a consistent API across these platforms, the DOM does not address memory management issues at all, but instead leaves these for the implementation. Neither of the explicit language bindings devised by the DOM Working Group (for ECMAScript and Java) require any memory management methods, but DOM bindings for other languages (especially C or C++) may require such support. These extensions will be the responsibility of those adapting the DOM API to a specific language, not the DOM Working Group.
While it would
be nice to have attribute and method names that are short,
informative, internally consistent, and familiar to users of
similar APIs, the names also should not clash with the names
in legacy APIs supported by DOM implementations.
Furthermore, both OMG IDL and ECMAScript
have
significant limitations in their ability to disambiguate names
from different namespaces that make it difficult to avoid naming
conflicts with short, familiar names. So, some DOM names tend to be
long and quite descriptive in order to be unique across all
environments.
The Working Group has also attempted to be internally consistent in its use of various terms, even though these may not be common distinctions in other APIs. For example, we use the method name "remove" when the method changes the structural model, and the method name "delete" when the method gets rid of something inside the structure model. The thing that is deleted is not returned. The thing that is removed may be returned, when it makes sense to return it.
The DOM Core APIs present two somewhat different sets of
interfaces to an XML/HTML document: one presenting an "object
oriented" approach with a hierarchy of inheritance, and a
"simplified" view that allows all manipulation to be done via
the Node
interface without requiring casts (in
Java and other C-like languages) or query interface calls in
COM environments. These operations are fairly expensive in Java and
COM, and the DOM may be used in performance-critical
environments, so we allow significant functionality using just the
Node
interface. Because many other users will find the
inheritance hierarchy easier to understand than the
"everything is a Node
" approach to the DOM, we also
support the full higher-level interfaces for those who prefer a more
object-oriented API.
In practice, this means that there is a certain amount of
redundancy in the API. The Working Group considers the
"inheritance" approach the primary view of the API, and the
full set of functionality on Node
to be "extra"
functionality that users may employ, but that does not eliminate
the need for methods on other interfaces that an
object-oriented analysis would dictate. (Of course, when the
O-O analysis yields an attribute or method that is
identical to one on the Node
interface, we don't
specify a completely redundant one.) Thus, even though there
is a generic nodeName
attribute on the Node
interface, there is still a tagName
attribute on the
Element
interface; these two attributes must
contain the same value, but the Working Group considers it
worthwhile to support both, given the different constituencies
the DOM API must satisfy.
DOMString
typeTo ensure interoperability, the DOM specifies the following:
A DOMString
is a sequence of 16-bit units.
typedef sequence<unsigned short> DOMString;
DOMString
using UTF-16
(defined in [Unicode] and Amendment 1 of
[ISO/IEC 10646]).DOMString
(a high surrogate and
a low surrogate).Note: Even though the DOM defines the name of the string type to
be DOMString
, bindings may use different names. For
example for Java, DOMString
is bound to the
String
type because it also uses UTF-16 as its
encoding.
Note: As of August 1998, the OMG IDL specification included a
wstring
type. However, that definition did not meet the
interoperability criteria of the DOM API since it relied on negotiation
to decide the width and encoding of a character.
DOMTimeStamp
typeTo ensure interoperability, the DOM specifies the following:
A DOMTimeStamp
represents a number of milliseconds.
typedef unsigned long long DOMTimeStamp;
Note:
Even though the DOM uses the type DOMTimeStamp
,
bindings may use different types. For example for Java,
DOMTimeStamp
is bound to the long
type. In ECMAScript, because TimeStamp
is bound to
the Date
type because the range of the integer type
is too small.
The DOM has many interfaces that imply string matching. HTML
processors generally assume an uppercase (less often,
lowercase) normalization of names for such things as elements,
while XML is explicitly case sensitive. For the purposes of
the DOM, string matching is performed purely by binary
comparison of the 16-bit
units of the DOMString
. In addition,
the DOM assumes that any case normalizations take place in the
processor, before the DOM structures are
built.
Note: Besides case folding, there are additional normalizations that can be applied to text. The W3C I18N Working Group is in the process of defining exactly which normalizations are necessary, and where they should be applied. The W3C I18N Working Group expects to require early normalization, which means that data read into the DOM is assumed to already be normalized. The DOM and applications built on top of it in this case only have to assure that text remains normalized when being changed. For further details, please see [Charmod].
The DOM Level 2 supports XML namespaces [Namespaces] by augmenting several interfaces of the DOM Level 1 Core to allow creating and manipulating elements and attributes associated to a namespace.
As far as the DOM is concerned, special attributes used for declaring XML namespaces are still exposed and can be manipulated just like any other attribute. However, nodes are permanently bound to namespace URIs as they get created. Consequently, moving a node within a document, using the DOM, in no case results in a change of its namespace prefix or namespace URI. Similarly, creating a node with a namespace prefix and namespace URI, or changing the namespace prefix of a node, does not result in any addition, removal, or modification of any special attributes for declaring the appropriate XML namespaces. Namespace validation is not enforced; the DOM application is responsible. In particular, since the mapping between prefixes and namespace URIs is not enforced, in general, the resulting document cannot be serialized naively. For example, applications may have to declare every namespace in use when serializing a document.
Note: In the DOM, all namespace declaration attributes are by definition bound to the namespace URI: "http://www.w3.org/2000/xmlns/". These are the attributes whose namespace prefix or qualified name is "xmlns". Although, at the time of writing, this is not part of the XML Namespaces [Namespaces], it is planned to be incorporated in a future revision.
In a document with no namespaces, the child list of an
EntityReference
node is always the same as that of the
corresponding Entity
. This is not true in a document where
an entity contains unbound namespace
prefixes. In such a case, the descendants of the
corresponding EntityReference
nodes may be bound to
different namespace URIs,
depending on where the entity references are. Also, because, in the
DOM, nodes always remain bound to the same namespace URI, moving such
EntityReference
nodes can lead to documents that cannot be
serialized. This is also true when the DOM Level 1 method
createEntityReference
of the Document
interface is used to create entity references that correspond to such
entities, since the descendants of the returned
EntityReference
are unbound. The DOM Level 2 does not
support any mechanism to resolve namespace prefixes. For all of these
reasons, use of such entities and entity references should be avoided
or used with extreme care. A future level of the DOM may include some
additional support for handling these.
The new methods, such as createElementNS
and
createAttributeNS
of the Document
interface,
are meant to be used by namespace aware applications. Simple
applications that do not use namespaces can use the DOM Level 1
methods, such as createElement
and
createAttribute
. Elements and attributes created in this
way do not have any namespace prefix, namespace URI, and local
name.
Note: DOM Level 1 methods are namespaces ignorant. Therefore, while it
is safe to use these methods when not dealing with namespaces, using
them and the new ones at the same time should be avoided. DOM Level 1
methods solely identify attribute nodes by their nodeName
.
On the contrary, the DOM Level 2 methods related to namespaces,
identify attribute nodes by their namespaceURI
and
localName
. Because of this fundamental difference, mixing
both sets of methods can lead to unpredictable results. In particular,
using setAttributeNS
, one can set on an element two
attributes (or more) that have the same nodeName
, but
different namespaceURIs
. Calling getAttribute
with that nodeName
could then return any of those
attributes. The result is implementation dependent. Similarly, using
setAttributeNode
, one can set two attributes (or more)
that have different nodeNames
but the same
prefix
and namespaceURI
. In this case
getAttributeNodeNS
will return one or the other, in an
implementation dependent manner. The only guarantee in such cases, is
that setAttribute
and setAttributeNS
affect
the node that, respectively, getAttribute
and
getAttributeNS
return.
The interfaces within this section are considered fundamental, and must be fully implemented by all conforming implementations of the DOM, including all HTML DOM implementations, unless otherwise specified.
DOM operations only raise exceptions in "exceptional"
circumstances, i.e., when an operation is impossible
to perform (either for logical reasons, because data is lost, or
because the implementation has become unstable). In general, DOM methods
return specific error values in ordinary
processing situations, such as out-of-bound errors when using
NodeList
.
Implementations may raise other exceptions under other circumstances.
For example, implementations may raise an implementation-dependent
exception if a null
argument is passed.
Some languages and object systems do not support the concept of exceptions. For such systems, error conditions may be indicated using native error reporting mechanisms. For some bindings, for example, methods may return error codes similar to those listed in the corresponding method descriptions.
exception DOMException { unsigned short code; }; // ExceptionCode const unsigned short INDEX_SIZE_ERR = 1; const unsigned short DOMSTRING_SIZE_ERR = 2; const unsigned short HIERARCHY_REQUEST_ERR = 3; const unsigned short WRONG_DOCUMENT_ERR = 4; const unsigned short INVALID_CHARACTER_ERR = 5; const unsigned short NO_DATA_ALLOWED_ERR = 6; const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7; const unsigned short NOT_FOUND_ERR = 8; const unsigned short NOT_SUPPORTED_ERR = 9; const unsigned short INUSE_ATTRIBUTE_ERR = 10; // Introduced in DOM Level 2: const unsigned short INVALID_STATE_ERR = 11; // Introduced in DOM Level 2: const unsigned short SYNTAX_ERR = 12; // Introduced in DOM Level 2: const unsigned short INVALID_MODIFICATION_ERR = 13; // Introduced in DOM Level 2: const unsigned short NAMESPACE_ERR = 14; // Introduced in DOM Level 2: const unsigned short INVALID_ACCESS_ERR = 15;
An integer indicating the type of error generated.
Note: Other numeric codes are reserved for W3C for possible future use.
DOMSTRING_SIZE_ERR | If the specified range of text does not fit into a DOMString |
HIERARCHY_REQUEST_ERR | If any node is inserted somewhere it doesn't belong |
INDEX_SIZE_ERR | If index or size is negative, or greater than the allowed value |
INUSE_ATTRIBUTE_ERR | If an attempt is made to add an attribute that is already in use elsewhere |
INVALID_ACCESS_ERR |
Introduced in DOM Level 2. If a parameter or an operation is not supported by the underlying object. |
INVALID_CHARACTER_ERR | If an invalid or illegal character is specified, such as in a name. See production 2 in the XML specification for the definition of a legal character, and production 5 for the definition of a legal name character. |
INVALID_MODIFICATION_ERR |
Introduced in DOM Level 2. If an attempt is made to modify the type of the underlying object. |
INVALID_STATE_ERR |
Introduced in DOM Level 2. If an attempt is made to use an object that is not, or is no longer, usable. |
NAMESPACE_ERR |
Introduced in DOM Level 2. If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces. |
NOT_FOUND_ERR | If an attempt is made to reference a node in a context where it does not exist |
NOT_SUPPORTED_ERR | If the implementation does not support the type of object requested |
NO_DATA_ALLOWED_ERR | If data is specified for a node which does not support data |
NO_MODIFICATION_ALLOWED_ERR | If an attempt is made to modify an object where modifications are not allowed |
SYNTAX_ERR |
Introduced in DOM Level 2. If an invalid or illegal string is specified. |
WRONG_DOCUMENT_ERR | If a node is used in a different document than the one that created it (that doesn't support it) |
The DOMImplementation
interface provides a
number of methods for performing operations that are independent
of any particular instance of the document object model.
interface DOMImplementation { boolean hasFeature(in DOMString feature, in DOMString version); // Introduced in DOM Level 2: DocumentType createDocumentType(in DOMString qualifiedName, in DOMString publicId, in DOMString systemId) raises(DOMException); // Introduced in DOM Level 2: Document createDocument(in DOMString namespaceURI, in DOMString qualifiedName, in DocumentType doctype) raises(DOMException); };
createDocument
introduced in DOM Level 2Document
object of the specified type
with its document element. HTML-only DOM implementations do not need to
implement this method.
| The namespace URI of
the document element to create, or | |||
| The qualified name of the document element to be created. | |||
| The type of document to be created or When |
INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character. NAMESPACE_ERR: Raised if the WRONG_DOCUMENT_ERR: Raised if |
createDocumentType
introduced in DOM Level 2DocumentType
node. Entity
declarations and notations are not made available. Entity reference
expansions and default attribute additions do not occur. It is expected
that a future version of the DOM will provide a way for populating a
DocumentType
.
| The qualified name of the document type to be created. | |||
| The external subset public identifier. | |||
| The external subset system identifier. |
A new |
INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character. NAMESPACE_ERR: Raised if the |
hasFeature
| The name of the feature to test (case-insensitive). The legal values are defined throughout this specification and listed in the Compliance section. The name must be an XML name. To avoid possible conflicts, as a convention, names referring to features defined outside the DOM spec should be made unique by reversing the name of the Internet domain name of the person (or the organization that person belongs to) who defines the feature, component by component, and use this as a prefix. For instance, the W3C SYMM Working Group defines the feature "org.w3c.dom.smil". | |||
| This is the version number of the feature to test. In Level
2, this is the string "2.0". If the version is not specified,
supporting any version of the feature causes the method to return
|
|
|
DocumentFragment
is a "lightweight" or "minimal"
Document
object. It is very common to want to be able to
extract a portion of a document's tree or to create a new fragment of a
document. Imagine implementing a user command like cut or rearranging a
document by moving fragments around. It is desirable to have an object
which can hold such fragments and it is quite natural to use a Node for
this purpose. While it is true that a Document
object could
fulfill this role, a Document
object can potentially be a
heavyweight object, depending on the underlying implementation. What is
really needed for this is a very lightweight object.
DocumentFragment
is such an object.
Furthermore, various operations -- such as inserting nodes as children
of another Node
-- may take DocumentFragment
objects as arguments; this results in all the child nodes of the
DocumentFragment
being moved to the child list of this
node.
The children of a DocumentFragment
node are zero or more
nodes representing the tops of any sub-trees defining the structure of
the document. DocumentFragment
nodes do not need to be
well-formed XML documents (although they do need to follow the rules
imposed upon well-formed XML parsed entities, which can have multiple top
nodes). For example, a DocumentFragment
might have only one
child and that child node could be a Text
node. Such a
structure model represents neither an HTML document nor a well-formed XML
document.
When a DocumentFragment
is inserted into a
Document
(or indeed any other Node
that may
take children) the children of the DocumentFragment
and not
the DocumentFragment
itself are inserted into the
Node
. This makes the DocumentFragment
very
useful when the user wishes to create nodes that are siblings; the
DocumentFragment
acts as the parent of these nodes so that
the user can use the standard methods from the Node
interface, such as insertBefore
and
appendChild
.
interface DocumentFragment : Node { };
The Document
interface represents the entire
HTML or XML document. Conceptually, it is the root of the
document tree, and provides the primary access to the
document's data.
Since elements, text nodes, comments, processing instructions,
etc. cannot exist outside the context of a Document
, the
Document
interface also contains the factory methods needed
to create these objects. The Node
objects created have a
ownerDocument
attribute which associates them with the
Document
within whose context they were created.
interface Document : Node { readonly attribute DocumentType doctype; readonly attribute DOMImplementation implementation; readonly attribute Element documentElement; Element createElement(in DOMString tagName) raises(DOMException); DocumentFragment createDocumentFragment(); Text createTextNode(in DOMString data); Comment createComment(in DOMString data); CDATASection createCDATASection(in DOMString data) raises(DOMException); ProcessingInstruction createProcessingInstruction(in DOMString target, in DOMString data) raises(DOMException); Attr createAttribute(in DOMString name) raises(DOMException); EntityReference createEntityReference(in DOMString name) raises(DOMException); NodeList getElementsByTagName(in DOMString tagname); // Introduced in DOM Level 2: Node importNode(in Node importedNode, in boolean deep) raises(DOMException); // Introduced in DOM Level 2: Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); // Introduced in DOM Level 2: Attr createAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); // Introduced in DOM Level 2: NodeList getElementsByTagNameNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: Element getElementById(in DOMString elementId); };
doctype
of type DocumentType
, readonlyDocumentType
)
associated with this document. For HTML documents as well as XML
documents without a document type declaration this returns
null
. The DOM Level 2 does not support editing the
Document Type Declaration, therefore docType
cannot be
altered in any way, including through the use of methods, such as
insertNode
or removeNode
, inherited from
Node
.
documentElement
of type Element
, readonly
implementation
of type DOMImplementation
, readonlyDOMImplementation
object that handles this
document. A DOM application may use objects from multiple
implementations.
createAttribute
Attr
of the given name.
Note that the Attr
instance
can then be set on an Element
using the
setAttributeNode
method. createAttributeNS
method.
| The name of the attribute. |
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
createAttributeNS
introduced in DOM Level 2
| The namespace URI of the attribute to create. | |||
| The qualified name of the attribute to instantiate. |
A new
|
INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character. NAMESPACE_ERR: Raised if the |
createCDATASection
CDATASection
node whose value is
the specified string.
| The data for the |
The new |
NOT_SUPPORTED_ERR: Raised if this document is an HTML document. |
createComment
createDocumentFragment
DocumentFragment
object.
A new |
createElement
Element
interface, so attributes
can be specified directly on the returned object.Attr
nodes representing them are automatically created and
attached to the element.createElementNS
method.
| The name of the element type to
instantiate. For XML, this is case-sensitive. For HTML, the
|
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
createElementNS
introduced in DOM Level 2
| The namespace URI of the element to create. | |||
| The qualified name of the element type to instantiate. |
A new
|
INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character. NAMESPACE_ERR: Raised if the |
createEntityReference
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 does
not support any mechanism to resolve namespace prefixes.
| The name of the entity to reference. |
The new |
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. NOT_SUPPORTED_ERR: Raised if this document is an HTML document. |
createProcessingInstruction
ProcessingInstruction
node given
the specified name and data strings.
The new |
INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character. NOT_SUPPORTED_ERR: Raised if this document is an HTML document. |
createTextNode
getElementById
introduced in DOM Level 2Element
whose ID
is given by elementId
. If no such element exists, returns
null
. Behavior is not defined if more than one element has
this ID
.
Note: The DOM implementation must have information that says which
attributes are of type ID. Attributes with the name "ID" are not of type ID unless
so defined. Implementations that do not know whether attributes are of type
ID or not are expected to return null
.
| The unique |
The matching element. |
getElementsByTagName
getElementsByTagNameNS
introduced in DOM Level 2NodeList
of all the Elements
with a given local name and
namespace URI in the order in which they would be encountered in a
preorder traversal of the Document
tree.
| The namespace URI of the elements to match on. The special value "*" matches all namespaces. | |||
| The local name of the elements to match on. The special value "*" matches all local names. |
importNode
introduced in DOM Level 2parentNode
is null
). The
source node is not altered or removed from the original document; this
method creates a new copy of the source node.nodeName
and nodeType
, plus the
attributes related to namespaces (prefix
,
localName
, and namespaceURI
). As in the
cloneNode
operation on a Node
, the source
node is not altered.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 every type of
node.
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.deep
parameter does not apply to
Attr
nodes; they always carry their children with
them when imported.deep
option was set true
,
the descendants of the source element will be recursively
imported and the resulting nodes reassembled to form the
corresponding subtree. Otherwise, this simply generates an
empty DocumentFragment
.Document
nodes cannot be imported.DocumentType
nodes cannot be imported.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 will be recursively imported
and the resulting nodes reassembled to form the corresponding
subtree.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.publicId
, systemId
,
and notationName
attributes are copied. If a
deep
import is requested, the descendants of the
the source Entity
is recursively imported and the
resulting nodes reassembled to form the corresponding
subtree.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
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.publicId
and
systemId
attributes are copied.deep
parameter does not apply to
Notation
nodes since they never have any
children.target
and
data
values from those of the source node.CharacterData
copy their data
and
length
attributes from those of the source
node.
| The node to import. | |||
|
| If |
The imported node that belongs to this
|
NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported. |
The Node
interface is the primary datatype for the
entire Document Object Model. It represents a single node in the
document tree. While all objects implementing the
Node
interface expose methods for dealing with
children, not all objects implementing the Node
interface may have children. For example, Text
nodes may not have children, and adding children to such nodes
results in a DOMException
being raised.
The attributes nodeName
, nodeValue
and
attributes
are included as a mechanism to get at node
information without casting down to the specific derived interface. In
cases where there is no obvious mapping of these attributes for a
specific nodeType
(e.g., nodeValue
for an
Element
or attributes
for a
Comment
), this returns null
. Note that the
specialized interfaces may contain additional and more convenient
mechanisms to get and set the relevant information.
interface Node { // NodeType const unsigned short ELEMENT_NODE = 1; const unsigned short ATTRIBUTE_NODE = 2; const unsigned short TEXT_NODE = 3; const unsigned short CDATA_SECTION_NODE = 4; const unsigned short ENTITY_REFERENCE_NODE = 5; const unsigned short ENTITY_NODE = 6; const unsigned short PROCESSING_INSTRUCTION_NODE = 7; const unsigned short COMMENT_NODE = 8; const unsigned short DOCUMENT_NODE = 9; const unsigned short DOCUMENT_TYPE_NODE = 10; const unsigned short DOCUMENT_FRAGMENT_NODE = 11; const unsigned short NOTATION_NODE = 12; readonly attribute DOMString nodeName; attribute DOMString nodeValue; // raises(DOMException) on setting // raises(DOMException) on retrieval readonly attribute unsigned short nodeType; readonly attribute Node parentNode; readonly attribute NodeList childNodes; readonly attribute Node firstChild; readonly attribute Node lastChild; readonly attribute Node previousSibling; readonly attribute Node nextSibling; readonly attribute NamedNodeMap attributes; // Modified in DOM Level 2: readonly attribute Document ownerDocument; Node insertBefore(in Node newChild, in Node refChild) raises(DOMException); Node replaceChild(in Node newChild, in Node oldChild) raises(DOMException); Node removeChild(in Node oldChild) raises(DOMException); Node appendChild(in Node newChild) raises(DOMException); boolean hasChildNodes(); Node cloneNode(in boolean deep); // Introduced in DOM Level 2: void normalize(); // Introduced in DOM Level 2: boolean supports(in DOMString feature, in DOMString version); // Introduced in DOM Level 2: readonly attribute DOMString namespaceURI; // Introduced in DOM Level 2: attribute DOMString prefix; // raises(DOMException) on setting // Introduced in DOM Level 2: readonly attribute DOMString localName; };
An integer indicating which type of node this is.
Note: Numeric codes up to 200 are reserved to W3C for possible future use.
ATTRIBUTE_NODE |
The node is an Attr . |
CDATA_SECTION_NODE |
The node is a CDATASection . |
COMMENT_NODE |
The node is a Comment . |
DOCUMENT_FRAGMENT_NODE |
The node is a DocumentFragment . |
DOCUMENT_NODE |
The node is a Document . |
DOCUMENT_TYPE_NODE |
The node is a DocumentType . |
ELEMENT_NODE |
The node is an Element . |
ENTITY_NODE |
The node is an Entity . |
ENTITY_REFERENCE_NODE |
The node is an EntityReference . |
NOTATION_NODE |
The node is a Notation . |
PROCESSING_INSTRUCTION_NODE |
The node is a ProcessingInstruction . |
TEXT_NODE |
The node is a Text node. |
The values of nodeName
, nodeValue
,
and attributes
vary according to the node type as follows:
nodeName | nodeValue | attributes | |
Attr | name of attribute | value of attribute | null |
CDATASection | #cdata-section | content of the CDATA Section | null |
Comment | #comment | content of the comment | null |
Document | #document | null | null |
DocumentFragment | #document-fragment | null | null |
DocumentType | document type name | null | null |
Element | tag name | null | NamedNodeMap |
Entity | entity name | null | null |
EntityReference | name of entity referenced | null | null |
Notation | notation name | null | null |
ProcessingInstruction | target | entire content excluding the target | null |
Text | #text | content of the text node | null |
attributes
of type NamedNodeMap
, readonlyNamedNodeMap
containing the
attributes of this node (if it is an Element
) or
null
otherwise.
childNodes
of type NodeList
, readonlyNodeList
that contains all children of this
node. If there are no children, this is a NodeList
containing no nodes.
firstChild
of type Node
, readonlynull
.
lastChild
of type Node
, readonlynull
.
localName
of type DOMString
, readonly, introduced in DOM Level 2createElement
from the Document
interface, it is null
.
namespaceURI
of type DOMString
, readonly, introduced in DOM Level 2null
if it is unspecified.ELEMENT_NODE
and ATTRIBUTE_NODE
and nodes created with a DOM
Level 1 method, such as createElement
from the
Document
interface, this is always
null
.Note: Per the Namespaces in XML Specification [Namespaces] an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.
nextSibling
of type Node
, readonlynull
.
nodeName
of type DOMString
, readonly
nodeType
of type unsigned short
, readonly
nodeValue
of type DOMString
null
, setting it has no
effect.
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. |
DOMSTRING_SIZE_ERR: Raised when it would return more
characters than fit in a |
ownerDocument
of type Document
, readonly, modified in DOM Level 2Document
object associated with this node. This
is also the Document
object used to create new nodes. When
this node is a Document
or a DocumentType
which is not used with any Document
yet, this is
null
.
parentNode
of type Node
, readonlyAttr
, Document
,
DocumentFragment
, Entity
, and
Notation
may have a parent. However, if a node has just
been created and not yet added to the tree, or if it has been removed
from the tree, this is null
.
prefix
of type DOMString
, introduced in DOM Level 2null
if it is unspecified.nodeName
attribute, which holds the qualified name, as well as
the tagName
and name
attributes of
the Element
and Attr
interfaces,
when applicable.namespaceURI
and localName
do not change.
INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NAMESPACE_ERR: Raised if the specified |
previousSibling
of type Node
, readonlynull
.
appendChild
newChild
to the end of the list of
children of this node. If the newChild
is already in the
tree, it is first removed.
| The node to add. If it is a
|
The node added. |
HIERARCHY_REQUEST_ERR: Raised if this node is of a type
that does not allow children of the type of the WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the node being appended is readonly. |
cloneNode
parentNode
is null
.).Element
copies all attributes and their
values, including those generated by the XML processor to represent
defaulted attributes, but this method does not copy any text it
contains unless it is a deep clone, since the text is contained in a
child Text
node. Cloning an Attribute
directly, as opposed to be cloned as part of an Element
cloning operation, returns a specified attribute
(specified
is true
). Cloning any other type
of node simply returns a copy of this node.EntityReference
clone are readonly.
|
| If |
The duplicate node. |
hasChildNodes
|
|
insertBefore
newChild
before the
existing child node refChild
. If
refChild
is null
, insert
newChild
at the end of the list of children.newChild
is a DocumentFragment
object, all of its children are inserted, in the same order, before
refChild
. If the newChild
is already in the
tree, it is first removed.
The node being inserted. |
HIERARCHY_REQUEST_ERR: Raised if this node is of a type
that does not allow children of the type of the WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the node being inserted is readonly. NOT_FOUND_ERR: Raised if |
normalize
introduced in DOM Level 2Text
nodes in the full depth of the
sub-tree underneath this Node
, including attribute nodes,
into a "normal" form where only markup (e.g., tags, comments,
processing instructions, CDATA sections, and entity references)
separates Text
nodes, i.e., there are neither adjacent
Text
nodes nor empty Text
nodes. This can be
used to ensure that the DOM view of a document is the same as if it
were saved and re-loaded, and is useful when operations (such as
XPointer lookups) that depend on a particular document tree structure
are to be used.Note: In cases where the document contains CDATASections
, the
normalize operation alone may not be sufficient, since XPointers do
not differentiate between Text
nodes and
CDATASection
nodes.
removeChild
oldChild
from
the list of children, and returns it.
| The node being removed. |
The node removed. |
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NOT_FOUND_ERR: Raised if |
replaceChild
oldChild
with
newChild
in the list of children, and returns the
oldChild
node.newChild
is a DocumentFragment
object,
oldChild
is replaced by all of the
DocumentFragment
children, which are inserted in the same
order. If the newChild
is already in the tree, it is
first removed.
The node replaced. |
HIERARCHY_REQUEST_ERR: Raised if this node is of a type
that does not allow children of the type of the WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the new node is readonly. NOT_FOUND_ERR: Raised if |
supports
introduced in DOM Level 2
| The name of the feature to test. This is the same
name which can be passed to the method | |||
| This is the version number of the feature to test. In
Level 2, version 1, this is the string "2.0". If the version is not
specified, supporting any version of the feature will cause the
method to return |
|
Returns |
The NodeList
interface provides the abstraction of an
ordered collection of nodes, without defining or constraining how this
collection is implemented. NodeList
objects in the DOM are
live.
The items in the NodeList
are accessible via an
integral index, starting from 0.
interface NodeList { Node item(in unsigned long index); readonly attribute unsigned long length; };
length
of type unsigned long
, readonlylength-1
inclusive.
item
index
th item in the collection.
If index
is greater than or equal to the number
of nodes in the list, this returns null
.
|
| Index into the collection. |
The node at the |
Objects implementing the NamedNodeMap
interface are
used to represent collections of nodes that can be accessed by name. Note
that NamedNodeMap
does not inherit from
NodeList
; NamedNodeMaps
are not maintained in
any particular order. Objects contained in an object implementing
NamedNodeMap
may also be accessed by an ordinal index, but
this is simply to allow convenient enumeration of the contents of a
NamedNodeMap
, and does not imply that the DOM specifies an
order to these Nodes.
NamedNodeMap
objects in the DOM are live.
interface NamedNodeMap { Node getNamedItem(in DOMString name); Node setNamedItem(in Node arg) raises(DOMException); Node removeNamedItem(in DOMString name) raises(DOMException); Node item(in unsigned long index); readonly attribute unsigned long length; // Introduced in DOM Level 2: Node getNamedItemNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: Node setNamedItemNS(in Node arg) raises(DOMException); // Introduced in DOM Level 2: Node removeNamedItemNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); };
length
of type unsigned long
, readonly0
to length-1
inclusive.
getNamedItem
getNamedItemNS
introduced in DOM Level 2
| The namespace URI of the node to retrieve. | |||
| The local name of the node to retrieve. |
item
index
th item in the map.
If index
is greater than or equal to the number
of nodes in this map, this returns null
.
|
| Index into this map. |
The node at the |
removeNamedItem
Node
interface. If so, an attribute immediately appears
containing the default value as well as the corresponding namespace
URI, local name, and prefix when applicable.
| The |
The node removed from this map if a node with such a name exists. |
NOT_FOUND_ERR: Raised if there is no node named
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. |
removeNamedItemNS
introduced in DOM Level 2Node
interface. If so, an
attribute immediately appears containing the default value as well as
the corresponding namespace URI, local name, and prefix when
applicable.
| The namespace URI of the node to remove. | |||
| The local name of the node to remove. |
The node removed from this map if a node with such a local name and namespace URI exists. |
NOT_FOUND_ERR: Raised if there is no node with the specified
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. |
setNamedItem
nodeName
attribute. If a node with
that name is already present in this map, it is replaced by the new
one.nodeName
attribute is used to
derive the name which the node must be stored under, multiple
nodes of certain types (those that have a "special" string
value) cannot be stored as the names would clash. This is seen
as preferable to allowing nodes to be aliased.
| A node to store in this map. The node will later be
accessible using the value of its |
WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. INUSE_ATTRIBUTE_ERR: Raised if |
setNamedItemNS
introduced in DOM Level 2namespaceURI
and
localName
. If a node with that namespace URI and that
local name is already present in this map, it is replaced by the new
one.
| A node to store in this map. The node will later be
accessible using the value of its |
WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. INUSE_ATTRIBUTE_ERR: Raised if |
The CharacterData
interface extends Node with a set of
attributes and methods for accessing character data in the DOM. For
clarity this set is defined here rather than on each object that uses
these attributes and methods. No DOM objects correspond directly to
CharacterData
, though Text
and others do
inherit the interface from it. All offsets
in this
interface start from 0.
As explained in the DOMString
interface, text strings
in the DOM are represented in UTF-16, i.e. as a sequence of 16-bit
units. In the following, the term 16-bit units is used whenever
necessary to indicate that indexing on CharacterData is done in
16-bit units.
interface CharacterData : Node { attribute DOMString data; // raises(DOMException) on setting // raises(DOMException) on retrieval readonly attribute unsigned long length; DOMString substringData(in unsigned long offset, in unsigned long count) raises(DOMException); void appendData(in DOMString arg) raises(DOMException); void insertData(in unsigned long offset, in DOMString arg) raises(DOMException); void deleteData(in unsigned long offset, in unsigned long count) raises(DOMException); void replaceData(in unsigned long offset, in unsigned long count, in DOMString arg) raises(DOMException); };
data
of type DOMString
CharacterData
node. However, implementation limits may
mean that the entirety of a node's data may not fit into a single
DOMString
. In such cases, the user may call
substringData
to retrieve the data in appropriately sized
pieces.
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. |
DOMSTRING_SIZE_ERR: Raised when it would return more
characters than fit in a |
length
of type unsigned long
, readonlydata
and the
substringData
method below. This may have the value zero,
i.e., CharacterData
nodes may be empty.
appendData
data
provides access to the concatenation of
data
and the DOMString
specified.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
deleteData
data
and length
reflect the change.
|
| The offset from which to start removing. | ||
|
| The number of 16-bit units to delete. If the sum of
|
INDEX_SIZE_ERR: Raised if the specified NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
insertData
INDEX_SIZE_ERR: Raised if the specified NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
replaceData
|
| The offset from which to start replacing. | ||
|
| The number of 16-bit units to replace. If the sum of
| ||
| The |
INDEX_SIZE_ERR: Raised if the specified NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
substringData
|
| Start offset of substring to extract. | ||
|
| The number of 16-bit units to extract. |
The specified substring. If the sum of |
INDEX_SIZE_ERR: Raised if the specified DOMSTRING_SIZE_ERR: Raised if the specified range of text does
not fit into a |
The Attr
interface represents an attribute in an Element
object.
Typically the allowable values for the attribute are defined in a document
type definition.
Attr
objects inherit the Node
interface, but since they are not actually child nodes of the element
they describe, the DOM does not consider them part of the document
tree. Thus, the Node
attributes parentNode
,
previousSibling
, and nextSibling
have a
null
value for Attr
objects. The DOM takes the
view that attributes are properties of elements rather than having a
separate identity from the elements they are associated with;
this should make it more efficient to implement
such features as default attributes associated with all elements of a
given type. Furthermore, Attr
nodes may not be immediate children of a DocumentFragment
.
However, they can be associated with Element
nodes contained within
a DocumentFragment
.
In short, users and implementors of the DOM need to be aware that
Attr
nodes have some things in
common with other objects inheriting the Node
interface,
but they also are quite distinct.
The attribute's effective value is determined as follows: if this
attribute has been explicitly assigned any value, that value is the
attribute's effective value; otherwise, if there is a declaration for
this attribute, and that declaration includes a default value, then
that default value is the attribute's effective value; otherwise, the
attribute does not exist on this element in the structure model until
it has been explicitly added. Note that the nodeValue
attribute on the Attr
instance can also be used to
retrieve the string version of the attribute's value(s).
In XML, where the value of an attribute can contain entity references,
the child nodes of the Attr
node provide a representation in
which entity references are not expanded. These child nodes may be either
Text
or EntityReference
nodes. Because the
attribute type may be unknown, there are no tokenized attribute values.
interface Attr : Node { readonly attribute DOMString name; readonly attribute boolean specified; attribute DOMString value; // raises(DOMException) on setting // Introduced in DOM Level 2: readonly attribute Element ownerElement; };
name
of type DOMString
, readonly
ownerElement
of type Element
, readonly, introduced in DOM Level 2Element
node this attribute is attached to or
null
if this attribute is not in use.
specified
of type boolean
, readonlytrue
; otherwise, it is false
.
Note that the implementation is in charge of this attribute, not the
user. If the user changes the value of the attribute (even if it ends up
having the same value as the default value) then the specified
flag is automatically flipped to true
. To re-specify the
attribute as the default value from the DTD, the user must delete the
attribute. The implementation will then make a new attribute available
with specified
set to false
and the default value
(if one exists).specified
is true
, and the value is the
assigned value.
specified
is false
,
and the value is the default value in the DTD.
value
of type DOMString
getAttribute
on the
Element
interface.Text
node with the unparsed
contents of the string. I.e. any characters that an XML processor would
recognize as markup are instead treated as literal text.
See also the method setAttribute
on the
Element
interface.
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. |
The Element
interface represents an element in an HTML
or XML document. Elements may have attributes associated with them; since the
Element
interface inherits from Node
, the generic
Node
interface attribute attributes
may be used
to retrieve the set of all attributes for an element. There are methods on
the Element
interface to retrieve either an Attr
object by name or an attribute value by name. In XML, where an attribute
value may contain entity references, an Attr
object should be
retrieved to examine the possibly fairly complex sub-tree representing the
attribute value. On the other hand, in HTML, where all attributes have
simple string values, methods to directly access an attribute value can
safely be used as a convenience.
Note: In DOM Level 2, the method normalize
is
inherited from the Node
interface where it was
moved.
interface Element : Node { readonly attribute DOMString tagName; DOMString getAttribute(in DOMString name); void setAttribute(in DOMString name, in DOMString value) raises(DOMException); void removeAttribute(in DOMString name) raises(DOMException); Attr getAttributeNode(in DOMString name); Attr setAttributeNode(in Attr newAttr) raises(DOMException); Attr removeAttributeNode(in Attr oldAttr) raises(DOMException); NodeList getElementsByTagName(in DOMString name); // Introduced in DOM Level 2: DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: void setAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) raises(DOMException); // Introduced in DOM Level 2: void removeAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); // Introduced in DOM Level 2: Attr getAttributeNodeNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException); // Introduced in DOM Level 2: NodeList getElementsByTagNameNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: boolean hasAttribute(in DOMString name); // Introduced in DOM Level 2: boolean hasAttributeNS(in DOMString namespaceURI, in DOMString localName); };
tagName
of type DOMString
, readonly<elementExample id="demo"> ... </elementExample> ,
tagName
has the value
"elementExample"
. Note that this is
case-preserving in XML, as are all of the operations of the DOM.
The HTML DOM returns the tagName
of an HTML element
in the canonical uppercase form, regardless of the case in the
source HTML document.
getAttribute
getAttributeNS
introduced in DOM Level 2
| The namespace URI of the attribute to retrieve. | |||
| The local name of the attribute to retrieve. |
getAttributeNode
getAttributeNodeNS
method.
| The name ( |
getAttributeNodeNS
introduced in DOM Level 2Attr
node by local name and namespace
URI. HTML-only DOM implementations do not need to implement this
method.
| The namespace URI of the attribute to retrieve. | |||
| The local name of the attribute to retrieve. |
getElementsByTagName
NodeList
of all descendant elements with a
given tag name, in the order in which they would be encountered in a
preorder traversal of the Element
tree.
| The name of the tag to match on. The special value "*" matches all tags. |
A list of matching |
getElementsByTagNameNS
introduced in DOM Level 2NodeList
of all the Elements
with a given local name and namespace URI in the order in which they
would be encountered in a preorder traversal of the
Document
tree, starting from this node.
| The namespace URI of the elements to match on. The special value "*" matches all namespaces. | |||
| The local name of the elements to match on. The special value "*" matches all local names. |
hasAttribute
introduced in DOM Level 2true
when an attribute with a given name is
specified on this element or has a default value, false
otherwise.
| The name of the attribute to look for. |
|
|
hasAttributeNS
introduced in DOM Level 2true
when an attribute with a given local
name and namespace URI is specified on this element or has a default
value, false
otherwise. HTML-only DOM implementations do
not need to implement this method.
| The namespace URI of the attribute to look for. | |||
| The local name of the attribute to look for. |
|
|
removeAttribute
removeAttributeNS
method.
| The name of the attribute to remove. |
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
removeAttributeNS
introduced in DOM Level 2
| The namespace URI of the attribute to remove. | |||
| The local name of the attribute to remove. |
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
removeAttributeNode
Attr
has a default value it is immediately
replaced. The replacing attribute has the same namespace URI
and local name, as well as the original prefix, when
applicable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NOT_FOUND_ERR: Raised if |
setAttribute
Attr
node plus any Text
and
EntityReference
nodes, build the appropriate subtree, and
use setAttributeNode
to assign it as the value of an
attribute.setAttributeNS
method.
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
setAttributeNS
introduced in DOM Level 2qualifiedName
, and
its value is changed to be the value
parameter. This value
is a simple string; it is not parsed as it is being set. So any markup
(such as syntax to be recognized as an entity reference) is treated as
literal text, and needs to be appropriately escaped by the
implementation when it is written out. In order to assign an attribute
value that contains entity references, the user must create an
Attr
node plus any Text
and
EntityReference
nodes, build the appropriate subtree, and
use setAttributeNodeNS
or setAttributeNode
to
assign it as the value of an attribute.
| The namespace URI of the attribute to create or alter. | |||
| The qualified name of the attribute to create or alter. | |||
| The value to set in string form. |
INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NAMESPACE_ERR: Raised if the |
setAttributeNode
nodeName
) is already present in the element, it is replaced
by the new one.setAttributeNodeNS
method.
WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. INUSE_ATTRIBUTE_ERR: Raised if |
setAttributeNodeNS
introduced in DOM Level 2
If the |
WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. INUSE_ATTRIBUTE_ERR: Raised if |
The Text
interface inherits from
CharacterData
and represents the textual
content (termed
character
data in XML) of an Element
or Attr
.
If there is no markup inside an element's content, the text is contained
in a single object implementing the Text
interface that
is the only child of the element. If there is markup, it is parsed into
the information items (elements,
comments, etc.) and Text
nodes that form the list of children of the element.
When a document is first made available via the DOM, there is
only one Text
node for each block of text. Users may create
adjacent Text
nodes that represent the
contents of a given element without any intervening markup, but
should be aware that there is no way to represent the separations
between these nodes in XML or HTML, so they will not (in general)
persist between DOM editing sessions. The normalize()
method on Element
merges any such adjacent Text
objects into a single node for each block of text.
interface Text : CharacterData { Text splitText(in unsigned long offset) raises(DOMException); };
splitText
offset
, keeping both in the tree as
siblings. This node then only contains all the content up to the
offset
point. A new node of the same type, which is
inserted as the next sibling of this node, contains all the content at
and after the offset
point. When the offset
is equal to the length of this node, the new node has
no data.
|
| The 16-bit unit
offset at which to split, starting from |
The new node, of the same type as this node. |
INDEX_SIZE_ERR: Raised if the specified offset is negative or
greater than the number of 16-bit units in NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
This interface inherits from CharacterData
and
represents the content of a comment, i.e., all the
characters between the starting '<!--
' and
ending '-->
'. Note that this is the definition
of a comment in XML, and, in practice, HTML, although some HTML
tools may implement the full SGML comment structure.
interface Comment : CharacterData { };
The interfaces defined here form part of the DOM Core specification, but objects that expose these interfaces will never be encountered in a DOM implementation that deals only with HTML. As such, HTML-only DOM implementations do not need to have objects that implement these interfaces.
A DOM application can use the hasFeature
method of the
DOMImplementation
interface to determine whether they
are supported or not. The feature string for all the interfaces listed in
this section is "XML".
CDATA sections are used to escape blocks of text containing characters that would otherwise be regarded as markup. The only delimiter that is recognized in a CDATA section is the "]]>" string that ends the CDATA section. CDATA sections cannot be nested. Their primary purpose is for including material such as XML fragments, without needing to escape all the delimiters.
The DOMString
attribute of the
Text
node holds the text that is contained by the CDATA
section. Note that this may contain characters
that need to be escaped outside of CDATA sections and that, depending on
the character encoding ("charset") chosen for serialization, it may be
impossible to write out some characters as part of a CDATA section.
The CDATASection
interface inherits from the
CharacterData
interface through the Text
interface. Adjacent CDATASections
nodes are not merged by
use of the normalize
method of the Element
interface.
Note: Because no markup is recognized within a CDATASection
,
character numeric references cannot be used as an escape mechanism
when serializing. Therefore, action needs to be taken when serializing
a CDATASection
with a character encoding where some of
the contained characters cannot be represented. Failure to do so would
not produce well-formed XML.
One potential solution in the serialization process is to end the
CDATA section before the character, output the character using a
character reference or entity reference, and open a new CDATA section
for any further characters in the text node. Note, however, that some
code conversion libraries at the time of writing do not return an
error or exception when a character is missing from the encoding,
making the task of ensuring that data is not corrupted on serialization
more difficult.
interface CDATASection : Text { };
Each Document
has a doctype
attribute
whose value is either null
or a DocumentType
object. The DocumentType
interface in the DOM Core
provides an interface to the list of entities that are defined
for the document, and little else because the effect of
namespaces and the various XML schema efforts on DTD
representation are not clearly understood as of this writing.
The DOM Level 2 doesn't support editing DocumentType
nodes.
interface DocumentType : Node { readonly attribute DOMString name; readonly attribute NamedNodeMap entities; readonly attribute NamedNodeMap notations; // Introduced in DOM Level 2: readonly attribute DOMString publicId; // Introduced in DOM Level 2: readonly attribute DOMString systemId; // Introduced in DOM Level 2: readonly attribute DOMString internalSubset; };
entities
of type NamedNodeMap
, readonlyNamedNodeMap
containing the general entities, both
external and internal, declared in the DTD. Parameter entities are not
contained. Duplicates are discarded.
For example in:
<!DOCTYPE ex SYSTEM "ex.dtd" [ <!ENTITY foo "foo"> <!ENTITY bar "bar"> <!ENTITY bar "bar2"> <!ENTITY % baz "baz"> ]> <ex/>
foo
and
the first declaration of bar
but not the second declaration of
bar
or baz
. Every node in this map
also implements the Entity
interface.entities
cannot be altered in any way.
internalSubset
of type DOMString
, readonly, introduced in DOM Level 2Note: The actual content returned depends on how much information is available to the implementation. This may vary depending on various parameters, including the XML processor used to build the document.
name
of type DOMString
, readonlyDOCTYPE
keyword.
notations
of type NamedNodeMap
, readonlyNamedNodeMap
containing the
notations declared in the DTD. Duplicates are discarded. Every node in
this map also implements the Notation
interface.notations
cannot be altered in any way.
publicId
of type DOMString
, readonly, introduced in DOM Level 2
systemId
of type DOMString
, readonly, introduced in DOM Level 2
This interface represents a notation declared in the DTD. A notation
either declares, by name, the format of an unparsed entity (see section 4.7
of the XML 1.0 specification), or is used for formal declaration of
processing instruction targets (see section 2.6 of the XML 1.0
specification). The nodeName
attribute inherited from
Node
is set to the declared name of the notation.
The DOM Level 1 does not support editing Notation
nodes; they are therefore readonly.
A Notation
node does not have any parent.
interface Notation : Node { readonly attribute DOMString publicId; readonly attribute DOMString systemId; };
This interface represents an entity, either parsed or
unparsed, in an XML document. Note that this models the entity
itself not the entity declaration. Entity
declaration modeling has been left for a later Level of the DOM
specification.
The nodeName
attribute that is inherited from
Node
contains the name of the entity.
An XML processor may choose to completely expand entities before
the structure model is passed to the DOM; in this case there will
be no EntityReference
nodes in the document tree.
XML does not mandate that a non-validating XML processor read
and process entity declarations made in the external subset or
declared in external parameter entities. This means
that parsed entities declared in the external subset
need not be expanded by some classes of applications, and that
the replacement value of the entity may not be available. When the
replacement value is available, the corresponding
Entity
node's child list represents the structure of
that replacement text. Otherwise, the child list is empty.
The DOM Level 2 does not support editing Entity
nodes; if a user wants to make changes to the contents of an
Entity
, every related EntityReference
node
has to be replaced in the structure model by a clone of the
Entity
's contents, and then the desired changes must be made
to each of those clones instead. All the descendants of an
Entity
node are readonly.
An Entity
node does not have any parent.
Note: If the entity contains an unbound namespace prefix, the
namespaceURI
of the corresponding node in the
Entity
node subtree is null
. The same is
true for EntityReference
nodes that refer to this entity,
when they are created using the createEntityReference
method of the Document
interface. The DOM Level 2 does not
support any mechanism to resolve namespace prefixes.
interface Entity : Node { readonly attribute DOMString publicId; readonly attribute DOMString systemId; readonly attribute DOMString notationName; };
notationName
of type DOMString
, readonlynull
.
publicId
of type DOMString
, readonlynull
.
systemId
of type DOMString
, readonlynull
.
EntityReference
objects may be inserted into the
structure model when an entity reference is in the source document, or
when the user wishes to insert an entity reference. Note that character
references and references to predefined entities are considered to be
expanded by the HTML or XML processor so that characters are represented
by their Unicode equivalent rather than by an entity reference. Moreover,
the XML processor may completely expand references to entities while
building the structure model, instead of providing
EntityReference
objects. If it does provide such objects,
then for a given EntityReference
node, it may be that there
is no Entity
node representing the referenced entity. If
such an Entity
exists, then the subtree of the
EntityReference
node is in general a copy of the
Entity
node subtree. However, this may not be true when an
entity contains an unbound namespace
prefix. In such a case, because the namespace prefix resolution
depends on where the entity reference is, the descendants of the
EntityReference
node may be bound to different
namespace URIs.
As with the Entity
node, all descendants of the
EntityReference
are readonly.
interface EntityReference : Node { };
The ProcessingInstruction
interface
represents a "processing instruction", used in XML
as a way to keep processor-specific information in the text of the
document.
interface ProcessingInstruction : Node { readonly attribute DOMString target; attribute DOMString data; // raises(DOMException) on setting };
data
of type DOMString
?>
.
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. |
target
of type DOMString
, readonly
This section extends the Core API to describe objects and methods specific to HTML documents. In general, the functionality needed to manipulate hierarchical document structures, elements, and attributes will be found in the core section; functionality that depends on the specific elements defined in HTML will be found in this section.
The goals of the HTML-specific DOM API are:
The key differences between the core DOM and the HTML application of DOM is that the HTML Document Object Model exposes a number of convenience methods and properties that are consistent with the existing models and are more appropriate to script writers. In many cases, these enhancements are not applicable to a general DOM because they rely on the presence of a predefined DTD. The transitional and frameset DTDs for HTML 4.0 are assumed. Interoperability between implementations is only guaranteed for elements and attributes that are specified in the HTML 4.0 DTDs.
More specifically, this document includes the following specializations for HTML:
HTMLDocument
interface, derived from the core
Document
interface. HTMLDocument
specifies the operations and queries that can be made on a HTML
document.HTMLElement
interface, derived from the core
Element
interface. HTMLElement
specifies
the operations and queries that can be made on any HTML
element. Methods on HTMLElement
include those that
allow for the retrieval and modification of attributes that apply
to all HTML elements.HTMLElement
interface. For all such attributes, the derived interface for the
element contains explicit methods for setting and getting the
values.The DOM Level 2 includes mechanisms to access and modify style specified through CSS and defines an event model that can be used with HTML documents.
The interfaces found within this section are not mandatory. A DOM
application can use the hasFeature
method of the
DOMImplementation
interface to determine whether they
are supported or not. The feature string for all the interfaces listed in
this section is "HTML".
The interfaces in this specification are designed for HTML 4.0 documents, and not for XHTML 1.0 documents. Use of the HTML DOM with XHTML 1.0 documents may result in incorrect processing; see Appendix C11 in [XHTML10] for more information.
The HTML DOM follows a naming convention for properties, methods, events, collections, and data types. All names are defined as one or more English words concatenated together to form a single string.
The property or method name starts with the initial keyword in lowercase, and each subsequent word starts with a capital letter. For example, a property that returns document meta information such as the date the file was created might be named "fileDateCreated". In the ECMAScript binding, properties are exposed as properties of a given object. In Java, properties are exposed with get and set methods.
While most of the interfaces defined below can be mapped directly to elements defined in the HTML 4.0 Recommendation, some of them cannot. Similarly, not all attributes listed below have counterparts in the HTML 4.0 specification (and some do, but have been renamed to avoid conflicts with scripting languages). Interfaces and attribute definitions that have links to the HTML 4.0 specification have corresponding element and attribute definitions there; all others are added by this specification, either for convenience or backwards compatibility with DOM Level 0 implementations.
The HTMLDOMImplementation
interface extends the
DOMImplementation
interface with a method for creating an
HTML document instance.
// Introduced in DOM Level 2: interface HTMLDOMImplementation : DOMImplementation { HTMLDocument createHTMLDocument(in DOMString title); };
createHTMLDocument
HTMLDocument
object with the minimal tree
made of the following elements: HTML
, HEAD
,
TITLE
, and BODY
.
A new |
An HTMLCollection
is a list of nodes. An individual node
may be accessed by either ordinal index or the node's
name
or id
attributes. Note:
Collections in the HTML DOM are assumed to be live meaning
that they are automatically updated when the underlying document is
changed.
interface HTMLCollection { readonly attribute unsigned long length; Node item(in unsigned long index); Node namedItem(in DOMString name); };
length
of type unsigned long
, readonly
An HTMLDocument
is the root of the HTML
hierarchy and holds the entire content. 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:
Note: In DOM Level 2, the method getElementById
is
inherited from the Document
interface where it was
moved.
interface HTMLDocument : Document { attribute DOMString title; readonly attribute DOMString referrer; readonly attribute DOMString domain; readonly attribute DOMString URL; attribute HTMLElement body; readonly attribute HTMLCollection images; readonly attribute HTMLCollection applets; readonly attribute HTMLCollection links; readonly attribute HTMLCollection forms; readonly attribute HTMLCollection anchors; attribute DOMString cookie; void open(); void close(); void write(in DOMString text); void writeln(in DOMString text); NodeList getElementsByName(in DOMString elementName); };
URL
of type DOMString
, readonly
anchors
of type HTMLCollection
, readonlyA
) 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.
applets
of type HTMLCollection
, readonlyOBJECT
elements that include
applets and APPLET
(deprecated) elements in
a document.
body
of type HTMLElement
BODY
contents, returns the BODY
element. In frameset documents, this returns the outermost
FRAMESET
element.
cookie
of type DOMString
name=value;expires=date
.
domain
of type DOMString
, readonlynull
if the server cannot be identified by a domain name.
forms
of type HTMLCollection
, readonly
images
of type HTMLCollection
, readonlyIMG
elements in a document.
The behavior is limited to IMG
elements for
backwards compatibility.
links
of type HTMLCollection
, readonlyAREA
elements and
anchor (A
) elements in a document
with a value for the href
attribute.
referrer
of type DOMString
, readonly
title
of type DOMString
TITLE
element in the head of the document.
close
open()
and forces rendering.getElementsByName
open
write
open()
. The text is parsed into the document's structure
model.
| The string to be parsed into some structure in the document structure model. |
writeln
open()
. The text is parsed into the
document's structure model.
| The string to be parsed into some structure in the document structure model. |
HTML attributes are exposed as properties on the element object. The DOM naming conventions always determine the name of the exposed property, and is independent of the case of the attribute in the source document. The data type of the property is determined by the type of the attribute as determined by the HTML 4.0 transitional and frameset DTDs. The attributes have the semantics (including case-sensitivity) given in the HTML 4.0 specification.
The attributes are exposed as properties for compatibility
with DOM Level 0. This usage
is deprecated because it can not be generalized to all possible
attribute names, as is required both for XML and potentially for future
versions of HTML. We recommend the use of generic methods on the core
Element
interface for setting, getting and removing
attributes.
DTD Data Type | Object Model Data Type |
CDATA | DOMString |
Value list (e.g., (left | right | center)) | DOMString |
one-value Value list (e.g., (disabled)) | boolean |
Number | long int |
The return value of an attribute that has a data type that is a
value list is always capitalized, independent of the case of
the value in the source document. For example, if the value of
the align attribute on a P element is "left" then it is
returned as "Left". For attributes with the CDATA
data type, the case of the return value is that given in
the source document.
The return value of an attribute that is unspecified and does not have a default value is the empty string if the return type is a DOMString, false if the return type is a boolean and 0 if the return type is a number.
To avoid namespace conflicts, an attribute with the same
name as a keyword in one of our chosen binding languages is
prefixed. For HTML, the prefix used is "html".
For example, the for
attribute of the
LABEL
element
collides with loop construct naming conventions and is renamed
htmlFor
.
tagName
)The element type names exposed through a property are in
uppercase. For example, the body element type name is
exposed through the tagName
property as
BODY
.
All HTML element interfaces derive from this class. Elements that only
expose the HTML core attributes are represented by the base
HTMLElement
interface. These elements are as follows:
Note: The style
attribute of an HTML element is accessible
through the ElementCSSInlineStyle
interface which is defined
in the Document Object Model CSS.
interface HTMLElement : Element { attribute DOMString id; attribute DOMString title; attribute DOMString lang; attribute DOMString dir; attribute DOMString className; };
className
of type DOMString
dir
of type DOMString
id
of type DOMString
lang
of type DOMString
title
of type DOMString
Root of an HTML document. See the HTML element definition in HTML 4.0.
interface HTMLHtmlElement : HTMLElement { attribute DOMString version; };
version
of type DOMString
Document head information. See the HEAD element definition in HTML 4.0.
interface HTMLHeadElement : HTMLElement { attribute DOMString profile; };
profile
of type DOMString
The LINK
element specifies a link to an external
resource, and defines this document's relationship to that resource
(or vice versa). See the LINK
element definition in HTML 4.0 (see also the LinkStyle
interface in the Document Object Model StyleSheets module).
interface HTMLLinkElement : HTMLElement { attribute boolean disabled; attribute DOMString charset; attribute DOMString href; attribute DOMString hreflang; attribute DOMString media; attribute DOMString rel; attribute DOMString rev; attribute DOMString target; attribute DOMString type; };
charset
of type DOMString
disabled
of type boolean
href
of type DOMString
hreflang
of type DOMString
media
of type DOMString
rel
of type DOMString
rev
of type DOMString
target
of type DOMString
type
of type DOMString
The document title. See the TITLE element definition in HTML 4.0.
This contains generic meta-information about the document. See the META element definition in HTML 4.0.
interface HTMLMetaElement : HTMLElement { attribute DOMString content; attribute DOMString httpEquiv; attribute DOMString name; attribute DOMString scheme; };
content
of type DOMString
httpEquiv
of type DOMString
name
of type DOMString
scheme
of type DOMString
Document base URI. See the BASE element definition in HTML 4.0.
interface HTMLBaseElement : HTMLElement { attribute DOMString href; attribute DOMString target; };
href
of type DOMString
target
of type DOMString
This element is used for single-line text input. See the ISINDEX element definition in HTML 4.0. This element is deprecated in HTML 4.0.
interface HTMLIsIndexElement : HTMLElement { readonly attribute HTMLFormElement form; attribute DOMString prompt; };
form
of type HTMLFormElement
, readonlyFORM
element containing this control.
Returns null
if this control is not within the context of a form.
prompt
of type DOMString
Style information. See the STYLE
element definition in HTML 4.0, the Document Object Model CSS module and
the LinkStyle
interface in the Document Object Model StyleSheets module.
interface HTMLStyleElement : HTMLElement { attribute boolean disabled; attribute DOMString media; attribute DOMString type; };
disabled
of type boolean
media
of type DOMString
type
of type DOMString
The HTML document body. This element is always present in the DOM API, even if the tags are not present in the source document. See the BODY element definition in HTML 4.0.
interface HTMLBodyElement : HTMLElement { attribute DOMString aLink; attribute DOMString background; attribute DOMString bgColor; attribute DOMString link; attribute DOMString text; attribute DOMString vLink; };
aLink
of type DOMString
background
of type DOMString
bgColor
of type DOMString
link
of type DOMString
text
of type DOMString
vLink
of type DOMString
The FORM
element encompasses behavior similar to a
collection and an element. It provides direct access to the contained
input elements as well as the attributes of the form element. See the FORM element definition in HTML 4.0.
interface HTMLFormElement : HTMLElement { readonly attribute HTMLCollection elements; readonly attribute long length; attribute DOMString name; attribute DOMString acceptCharset; attribute DOMString action; attribute DOMString enctype; attribute DOMString method; attribute DOMString target; void submit(); void reset(); };
acceptCharset
of type DOMString
action
of type DOMString
elements
of type HTMLCollection
, readonly
enctype
of type DOMString
length
of type long
, readonly
method
of type DOMString
name
of type DOMString
target
of type DOMString
The select element allows the selection of an option. The contained options can be directly accessed through the select element as a collection. See the SELECT element definition in HTML 4.0.
interface HTMLSelectElement : HTMLElement { readonly attribute DOMString type; attribute long selectedIndex; attribute DOMString value; readonly attribute long length; readonly attribute HTMLFormElement form; readonly attribute HTMLCollection options; attribute boolean disabled; attribute boolean multiple; attribute DOMString name; attribute long size; attribute long tabIndex; void add(in HTMLElement element, in HTMLElement before) raises(DOMException); void remove(in long index); void blur(); void focus(); };
disabled
of type boolean
form
of type HTMLFormElement
, readonlyFORM
element containing this control.
Returns null
if this control is not within the context of a form.
length
of type long
, readonlySELECT
.
multiple
of type boolean
OPTION
elements may
be selected in this SELECT
. See the multiple attribute definition in HTML 4.0.
name
of type DOMString
options
of type HTMLCollection
, readonlyOPTION
elements contained by this element.
selectedIndex
of type long
size
of type long
tabIndex
of type long
type
of type DOMString
, readonlytrue
and
the string "select-one" when false
.
value
of type DOMString
add
OPTION
elements
for this SELECT
. This method is the equivalent of the
appendChild
method of the Node
interface if the before
parameter is null
. It
is equivalent to the insertBefore
method on
the parent of before
in all other cases.
| The element to add. | |||
| The element to insert before, or |
NOT_FOUND_ERR: Raised if |
blur
focus
remove
OPTION
elements
for this SELECT
. Does nothing if no element has the given
index.
|
| The index of the item to remove, starting from 0. |
Group options together in logical subdivisions. See the OPTGROUP element definition in HTML 4.0.
interface HTMLOptGroupElement : HTMLElement { attribute boolean disabled; attribute DOMString label; };
disabled
of type boolean
label
of type DOMString
A selectable choice. See the OPTION element definition in HTML 4.0.
interface HTMLOptionElement : HTMLElement { readonly attribute HTMLFormElement form; attribute boolean defaultSelected; readonly attribute DOMString text; readonly attribute long index; attribute boolean disabled; attribute DOMString label; attribute boolean selected; attribute DOMString value; };
defaultSelected
of type boolean
defaultSelected
, however, resets the
state of the form control. See the selected attribute definition in HTML 4.0.
disabled
of type boolean
form
of type HTMLFormElement
, readonlyFORM
element containing this control.
Returns null
if this control is not within the context of a form.
index
of type long
, readonlyOPTION
in its parent
SELECT
, starting from 0.
label
of type DOMString
selected
of type boolean
text
of type DOMString
, readonly
value
of type DOMString
Form control. Note. Depending upon the environment in which the page is being viewed, the value property may be read-only for the file upload input type. For the "password" input type, the actual value returned may be masked to prevent unauthorized use. See the INPUT element definition in HTML 4.0.
interface HTMLInputElement : HTMLElement { attribute DOMString defaultValue; attribute boolean defaultChecked; readonly attribute HTMLFormElement form; attribute DOMString accept; attribute DOMString accessKey; attribute DOMString align; attribute DOMString alt; attribute boolean checked; attribute boolean disabled; attribute long maxLength; attribute DOMString name; attribute boolean readOnly; attribute DOMString size; attribute DOMString src; attribute long tabIndex; readonly attribute DOMString type; attribute DOMString useMap; attribute DOMString value; void blur(); void focus(); void select(); void click(); };
accept
of type DOMString
accessKey
of type DOMString
align
of type DOMString
alt
of type DOMString
checked
of type boolean
type
attribute of the element has the
value "Radio" or "Checkbox", this represents the current state of the
form control, in an interactive user agent. Changes to this attribute
change the state of the form control, but do not change the value of
the HTML value attribute of the element.
defaultChecked
of type boolean
type
has the value "Radio" or "Checkbox",
this represents the HTML checked attribute of the element. The value of
this attribute does not change if the state of the corresponding form
control, in an interactive user agent, changes. Changes to this
attribute, however, resets the state of the form control. See the checked attribute definition in HTML 4.0.
defaultValue
of type DOMString
type
attribute of the element has the
value "Text", "File" or "Password", this represents the HTML value
attribute of the element. The value of this attribute does not change
if the contents of the corresponding form control, in an interactive
user agent, changes. Changing this attribute, however, resets the
contents of the form control. See the value attribute definition in HTML 4.0.
disabled
of type boolean
form
of type HTMLFormElement
, readonlyFORM
element containing this control.
Returns null
if this control is not within the context of a form.
maxLength
of type long
type
has the value "Text" or "Password". See the maxlength attribute definition in HTML 4.0.
name
of type DOMString
readOnly
of type boolean
type
has the value "Text" or "Password". See the readonly attribute definition in HTML 4.0.
size
of type DOMString
src
of type DOMString
type
attribute has the value "Image", this
attribute specifies the location of the image to be used to decorate
the graphical submit button. See the src attribute definition in HTML 4.0.
tabIndex
of type long
type
of type DOMString
, readonly
useMap
of type DOMString
value
of type DOMString
type
attribute of the element has the
value "Text", "File" or "Password", this represents the current
contents of the corresponding form control, in an interactive user
agent. Changing this attribute changes the contents of the form
control, but does not change the value of the HTML value attribute of
the element. When the type
attribute of the element has
the value "Button", "Hidden", "Submit", "Reset", "Image", "Checkbox" or
"Radio", this represents the HTML value attribute of the element. See
the value attribute definition in HTML 4.0.
blur
click
INPUT
elements whose
type
attribute has one of the following
values: "Button", "Checkbox", "Radio", "Reset", or "Submit".focus
select
INPUT
elements
whose type
attribute has one of the following values:
"Text", "File", or "Password".Multi-line text field. See the TEXTAREA element definition in HTML 4.0.
interface HTMLTextAreaElement : HTMLElement { attribute DOMString defaultValue; readonly attribute HTMLFormElement form; attribute DOMString accessKey; attribute long cols; attribute boolean disabled; attribute DOMString name; attribute boolean readOnly; attribute long rows; attribute long tabIndex; readonly attribute DOMString type; attribute DOMString value; void blur(); void focus(); void select(); };
accessKey
of type DOMString
cols
of type long
defaultValue
of type DOMString
disabled
of type boolean
form
of type HTMLFormElement
, readonlyFORM
element containing this control.
Returns null
if this control is not within the context of a form.
name
of type DOMString
readOnly
of type boolean
rows
of type long
tabIndex
of type long
type
of type DOMString
, readonly
value
of type DOMString
DOMString
, the implementation may truncate the
data.
Push button. See the BUTTON element definition in HTML 4.0.
interface HTMLButtonElement : HTMLElement { readonly attribute HTMLFormElement form; attribute DOMString accessKey; attribute boolean disabled; attribute DOMString name; attribute long tabIndex; readonly attribute DOMString type; attribute DOMString value; };
accessKey
of type DOMString
disabled
of type boolean
form
of type HTMLFormElement
, readonlyFORM
element containing this control.
Returns null
if this control is not within the context of a form.
name
of type DOMString
tabIndex
of type long
type
of type DOMString
, readonly
value
of type DOMString
Form field label text. See the LABEL element definition in HTML 4.0.
interface HTMLLabelElement : HTMLElement { readonly attribute HTMLFormElement form; attribute DOMString accessKey; attribute DOMString htmlFor; };
accessKey
of type DOMString
form
of type HTMLFormElement
, readonlyFORM
element containing this control.
Returns null
if this control is not within the context of a form.
htmlFor
of type DOMString
id
attribute. See the for attribute definition in HTML 4.0.
Organizes form controls into logical groups. See the FIELDSET element definition in HTML 4.0.
interface HTMLFieldSetElement : HTMLElement { readonly attribute HTMLFormElement form; };
form
of type HTMLFormElement
, readonlyFORM
element containing this control.
Returns null
if this control is not within the context of a form.
Provides a caption for a FIELDSET
grouping. See the LEGEND element definition in HTML 4.0.
interface HTMLLegendElement : HTMLElement { readonly attribute HTMLFormElement form; attribute DOMString accessKey; attribute DOMString align; };
accessKey
of type DOMString
align
of type DOMString
FIELDSET
. See the align attribute definition in HTML 4.0. This attribute is deprecated in HTML 4.0.
form
of type HTMLFormElement
, readonlyFORM
element containing this control.
Returns null
if this control is not within the context of a form.
Unordered list. See the UL element definition in HTML 4.0.
interface HTMLUListElement : HTMLElement { attribute boolean compact; attribute DOMString type; };
compact
of type boolean
type
of type DOMString
Ordered list. See the OL element definition in HTML 4.0.
interface HTMLOListElement : HTMLElement { attribute boolean compact; attribute long start; attribute DOMString type; };
compact
of type boolean
start
of type long
type
of type DOMString
Definition list. See the DL element definition in HTML 4.0.
interface HTMLDListElement : HTMLElement { attribute boolean compact; };
compact
of type boolean
Directory list. See the DIR element definition in HTML 4.0. This element is deprecated in HTML 4.0.
interface HTMLDirectoryElement : HTMLElement { attribute boolean compact; };
compact
of type boolean
Menu list. See the MENU element definition in HTML 4.0. This element is deprecated in HTML 4.0.
interface HTMLMenuElement : HTMLElement { attribute boolean compact; };
compact
of type boolean
List item. See the LI element definition in HTML 4.0.
interface HTMLLIElement : HTMLElement { attribute DOMString type; attribute long value; };
type
of type DOMString
value
of type long
OL
. See the value attribute definition in HTML 4.0. This attribute is deprecated in HTML 4.0.
Generic block container. See the DIV element definition in HTML 4.0.
interface HTMLDivElement : HTMLElement { attribute DOMString align; };
align
of type DOMString
Paragraphs. See the P element definition in HTML 4.0.
interface HTMLParagraphElement : HTMLElement { attribute DOMString align; };
align
of type DOMString
For the H1
to H6
elements. See the H1 element definition in HTML 4.0.
interface HTMLHeadingElement : HTMLElement { attribute DOMString align; };
align
of type DOMString
For the Q
and BLOCKQUOTE
elements. See the Q element definition in HTML 4.0.
interface HTMLQuoteElement : HTMLElement { attribute DOMString cite; };
cite
of type DOMString
Preformatted text. See the PRE element definition in HTML 4.0.
interface HTMLPreElement : HTMLElement { attribute long width; };
width
of type long
Force a line break. See the BR element definition in HTML 4.0.
interface HTMLBRElement : HTMLElement { attribute DOMString clear; };
clear
of type DOMString
Base font. See the BASEFONT element definition in HTML 4.0. This element is deprecated in HTML 4.0.
interface HTMLBaseFontElement : HTMLElement { attribute DOMString color; attribute DOMString face; attribute DOMString size; };
color
of type DOMString
face
of type DOMString
size
of type DOMString
Local change to font. See the FONT element definition in HTML 4.0. This element is deprecated in HTML 4.0.
interface HTMLFontElement : HTMLElement { attribute DOMString color; attribute DOMString face; attribute DOMString size; };
color
of type DOMString
face
of type DOMString
size
of type DOMString
Create a horizontal rule. See the HR element definition in HTML 4.0.
interface HTMLHRElement : HTMLElement { attribute DOMString align; attribute boolean noShade; attribute DOMString size; attribute DOMString width; };
align
of type DOMString
noShade
of type boolean
size
of type DOMString
width
of type DOMString
Notice of modification to part of a document. See the INS and DEL element definitions in HTML 4.0.
interface HTMLModElement : HTMLElement { attribute DOMString cite; attribute DOMString dateTime; };
cite
of type DOMString
dateTime
of type DOMString
The anchor element. See the A element definition in HTML 4.0.
interface HTMLAnchorElement : HTMLElement { attribute DOMString accessKey; attribute DOMString charset; attribute DOMString coords; attribute DOMString href; attribute DOMString hreflang; attribute DOMString name; attribute DOMString rel; attribute DOMString rev; attribute DOMString shape; attribute long tabIndex; attribute DOMString target; attribute DOMString type; void blur(); void focus(); };
accessKey
of type DOMString
charset
of type DOMString
coords
of type DOMString
shape
for the shape of the region. See the coords attribute definition in HTML 4.0.
href
of type DOMString
hreflang
of type DOMString
name
of type DOMString
rel
of type DOMString
rev
of type DOMString
shape
of type DOMString
coords
. See the shape attribute definition in HTML 4.0.
tabIndex
of type long
target
of type DOMString
type
of type DOMString
Embedded image. See the IMG element definition in HTML 4.0.
interface HTMLImageElement : HTMLElement { attribute DOMString lowSrc; attribute DOMString name; attribute DOMString align; attribute DOMString alt; attribute DOMString border; attribute DOMString height; attribute DOMString hspace; attribute boolean isMap; attribute DOMString longDesc; attribute DOMString src; attribute DOMString useMap; attribute DOMString vspace; attribute DOMString width; };
align
of type DOMString
alt
of type DOMString
border
of type DOMString
height
of type DOMString
hspace
of type DOMString
isMap
of type boolean
longDesc
of type DOMString
lowSrc
of type DOMString
name
of type DOMString
src
of type DOMString
useMap
of type DOMString
vspace
of type DOMString
width
of type DOMString
Generic embedded object. Note. In principle, all properties on the object element are read-write but in some environments some properties may be read-only once the underlying object is instantiated. See the OBJECT element definition in HTML 4.0.
interface HTMLObjectElement : HTMLElement { readonly attribute HTMLFormElement form; attribute DOMString code; attribute DOMString align; attribute DOMString archive; attribute DOMString border; attribute DOMString codeBase; attribute DOMString codeType; attribute DOMString data; attribute boolean declare; attribute DOMString height; attribute DOMString hspace; attribute DOMString name; attribute DOMString standby; attribute long tabIndex; attribute DOMString type; attribute DOMString useMap; attribute DOMString vspace; attribute DOMString width; // Introduced in DOM Level 2: attribute Document contentDocument; };
align
of type DOMString
archive
of type DOMString
border
of type DOMString
code
of type DOMString
code
attribute for
HTMLAppletElement.
codeBase
of type DOMString
classid
, data
, and
archive
attributes. See the codebase attribute definition in HTML 4.0.
codeType
of type DOMString
classid
attribute. See the codetype attribute definition in HTML 4.0.
contentDocument
of type Document
, introduced in DOM Level 2null
otherwise.
data
of type DOMString
declare
of type boolean
form
of type HTMLFormElement
, readonlyFORM
element containing this control.
Returns null
if this control is not within the context of a form.
height
of type DOMString
hspace
of type DOMString
name
of type DOMString
standby
of type DOMString
tabIndex
of type long
type
of type DOMString
data
attribute. See the type attribute definition in HTML 4.0.
useMap
of type DOMString
vspace
of type DOMString
width
of type DOMString
Parameters fed to the OBJECT
element. See the PARAM element definition in HTML 4.0.
interface HTMLParamElement : HTMLElement { attribute DOMString name; attribute DOMString type; attribute DOMString value; attribute DOMString valueType; };
name
of type DOMString
type
of type DOMString
value
attribute when
valuetype
has the value "ref". See the type attribute definition in HTML 4.0.
value
of type DOMString
valueType
of type DOMString
value
attribute
value. See the valuetype attribute definition in HTML 4.0.
An embedded Java applet. See the APPLET element definition in HTML 4.0. This element is deprecated in HTML 4.0.
interface HTMLAppletElement : HTMLElement { attribute DOMString align; attribute DOMString alt; attribute DOMString archive; attribute DOMString code; attribute DOMString codeBase; attribute DOMString height; attribute DOMString hspace; attribute DOMString name; attribute DOMString object; attribute DOMString vspace; attribute DOMString width; };
align
of type DOMString
alt
of type DOMString
archive
of type DOMString
code
of type DOMString
codeBase
of type DOMString
height
of type DOMString
hspace
of type DOMString
name
of type DOMString
object
of type DOMString
vspace
of type DOMString
width
of type DOMString
Client-side image map. See the MAP element definition in HTML 4.0.
interface HTMLMapElement : HTMLElement { readonly attribute HTMLCollection areas; attribute DOMString name; };
areas
of type HTMLCollection
, readonly
name
of type DOMString
usemap
). See the name attribute definition in HTML 4.0.
Client-side image map area definition. See the AREA element definition in HTML 4.0.
interface HTMLAreaElement : HTMLElement { attribute DOMString accessKey; attribute DOMString alt; attribute DOMString coords; attribute DOMString href; attribute boolean noHref; attribute DOMString shape; attribute long tabIndex; attribute DOMString target; };
accessKey
of type DOMString
alt
of type DOMString
coords
of type DOMString
shape
for the shape of the region. See the coords attribute definition in HTML 4.0.
href
of type DOMString
noHref
of type boolean
shape
of type DOMString
coords
. See the shape attribute definition in HTML 4.0.
tabIndex
of type long
target
of type DOMString
Script statements. See the SCRIPT element definition in HTML 4.0.
interface HTMLScriptElement : HTMLElement { attribute DOMString text; attribute DOMString htmlFor; attribute DOMString event; attribute DOMString charset; attribute boolean defer; attribute DOMString src; attribute DOMString type; };
charset
of type DOMString
defer
of type boolean
event
of type DOMString
htmlFor
of type DOMString
src
of type DOMString
text
of type DOMString
type
of type DOMString
The create* and delete* methods on the table allow authors to construct
and modify tables. HTML 4.0 specifies that only one of each of the
CAPTION
, THEAD
, and TFOOT
elements may exist in a table. Therefore, if one exists, and the
createTHead() or createTFoot() method is called, the method returns
the existing THead or TFoot element. See the TABLE element definition in HTML 4.0.
interface HTMLTableElement : HTMLElement { attribute HTMLTableCaptionElement caption; attribute HTMLTableSectionElement tHead; attribute HTMLTableSectionElement tFoot; readonly attribute HTMLCollection rows; readonly attribute HTMLCollection tBodies; attribute DOMString align; attribute DOMString bgColor; attribute DOMString border; attribute DOMString cellPadding; attribute DOMString cellSpacing; attribute DOMString frame; attribute DOMString rules; attribute DOMString summary; attribute DOMString width; HTMLElement createTHead(); void deleteTHead(); HTMLElement createTFoot(); void deleteTFoot(); HTMLElement createCaption(); void deleteCaption(); HTMLElement insertRow(in long index) raises(DOMException); void deleteRow(in long index) raises(DOMException); };
align
of type DOMString
bgColor
of type DOMString
border
of type DOMString
caption
of type HTMLTableCaptionElement
CAPTION
, or void if none exists.
cellPadding
of type DOMString
cellSpacing
of type DOMString
frame
of type DOMString
rows
of type HTMLCollection
, readonlyTHEAD
, TFOOT
, all
TBODY
elements.
rules
of type DOMString
summary
of type DOMString
tBodies
of type HTMLCollection
, readonly
tFoot
of type HTMLTableSectionElement
TFOOT
, or
null
if none exists.
tHead
of type HTMLTableSectionElement
THEAD
, or
null
if none exists.
width
of type DOMString
createCaption
A |
createTFoot
A footer element ( |
createTHead
A new table header element ( |
deleteCaption
deleteRow
|
| The index of the row to be deleted. This index starts from 0 and is relative to all the rows contained inside the table, regardless of section parentage. |
INDEX_SIZE_ERR: Raised if the specified index is greater than or equal to the number of rows or if the index is negative. |
deleteTFoot
deleteTHead
insertRow
index
th row in the table. If index
is
equal to the number of rows, the new row is appended. In addition, when
the table is empty the row is inserted into a TBODY
which
is created and inserted into the table.
Note. A table row cannot be empty
according to HTML 4.0 Recommendation.
|
| The row number where to insert a new row. This index starts from 0 and is relative to all the rows contained inside the table, regardless of section parentage. |
The newly created row. |
INDEX_SIZE_ERR: Raised if the specified index is greater than the number of rows or if the index is negative. |
Table caption See the CAPTION element definition in HTML 4.0.
interface HTMLTableCaptionElement : HTMLElement { attribute DOMString align; };
align
of type DOMString
Regroups the COL
and COLGROUP
elements. See the COL element definition in HTML 4.0.
interface HTMLTableColElement : HTMLElement { attribute DOMString align; attribute DOMString ch; attribute DOMString chOff; attribute long span; attribute DOMString vAlign; attribute DOMString width; };
align
of type DOMString
ch
of type DOMString
chOff
of type DOMString
span
of type long
vAlign
of type DOMString
width
of type DOMString
The THEAD
, TFOOT
, and TBODY
elements.
interface HTMLTableSectionElement : HTMLElement { attribute DOMString align; attribute DOMString ch; attribute DOMString chOff; attribute DOMString vAlign; readonly attribute HTMLCollection rows; HTMLElement insertRow(in long index) raises(DOMException); void deleteRow(in long index) raises(DOMException); };
align
of type DOMString
align
attribute for HTMLTheadElement for details.
ch
of type DOMString
chOff
of type DOMString
rows
of type HTMLCollection
, readonly
vAlign
of type DOMString
valign
attribute for HTMLTheadElement for details.
deleteRow
|
| The index of the row to be deleted. This index starts from 0 and is relative only to the rows contained inside this section, not all the rows in the table. |
INDEX_SIZE_ERR: Raised if the specified index is greater than or equal to the number of rows or if the index is negative. |
insertRow
index
th row in this
section. If index
is equal to the number of rows in this
section, the new row is appended.
|
| The row number where to insert a new row. This index starts from 0 and is relative only to the rows contained inside this section, not all the rows in the table. |
The newly created row. |
INDEX_SIZE_ERR: Raised if the specified index is greater than the number of rows of if the index is neagative. |
A row in a table. See the TR element definition in HTML 4.0.
interface HTMLTableRowElement : HTMLElement { readonly attribute long rowIndex; readonly attribute long sectionRowIndex; readonly attribute HTMLCollection cells; attribute DOMString align; attribute DOMString bgColor; attribute DOMString ch; attribute DOMString chOff; attribute DOMString vAlign; HTMLElement insertCell(in long index) raises(DOMException); void deleteCell(in long index) raises(DOMException); };
align
of type DOMString
bgColor
of type DOMString
cells
of type HTMLCollection
, readonly
ch
of type DOMString
chOff
of type DOMString
rowIndex
of type long
, readonlyrowIndex
does not take into account sections (THEAD
, TFOOT
, or TBODY
) within the table.
sectionRowIndex
of type long
, readonlyTHEAD
, TFOOT
, or TBODY
), starting from
0.
vAlign
of type DOMString
deleteCell
|
| The index of the cell to delete, starting from 0. |
INDEX_SIZE_ERR: Raised if the specified |
insertCell
TD
cell into this row. If
index
is equal to the number of cells, the new cell is
appended
|
| The place to insert the cell, starting from 0. |
The newly created cell. |
INDEX_SIZE_ERR: Raised if the specified |
The object used to represent the TH
and TD
elements. See the TD element definition in HTML 4.0.
interface HTMLTableCellElement : HTMLElement { readonly attribute long cellIndex; attribute DOMString abbr; attribute DOMString align; attribute DOMString axis; attribute DOMString bgColor; attribute DOMString ch; attribute DOMString chOff; attribute long colSpan; attribute DOMString headers; attribute DOMString height; attribute boolean noWrap; attribute long rowSpan; attribute DOMString scope; attribute DOMString vAlign; attribute DOMString width; };
abbr
of type DOMString
align
of type DOMString
axis
of type DOMString
bgColor
of type DOMString
cellIndex
of type long
, readonly
ch
of type DOMString
chOff
of type DOMString
colSpan
of type long
headers
of type DOMString
id
attribute values for header cells. See the headers attribute definition in HTML 4.0.
height
of type DOMString
noWrap
of type boolean
rowSpan
of type long
scope
of type DOMString
vAlign
of type DOMString
width
of type DOMString
Create a grid of frames. See the FRAMESET element definition in HTML 4.0.
interface HTMLFrameSetElement : HTMLElement { attribute DOMString cols; attribute DOMString rows; };
cols
of type DOMString
rows
of type DOMString
Create a frame. See the FRAME element definition in HTML 4.0.
interface HTMLFrameElement : HTMLElement { attribute DOMString frameBorder; attribute DOMString longDesc; attribute DOMString marginHeight; attribute DOMString marginWidth; attribute DOMString name; attribute boolean noResize; attribute DOMString scrolling; attribute DOMString src; // Introduced in DOM Level 2: attribute Document contentDocument; };
contentDocument
of type Document
, introduced in DOM Level 2null
otherwise.
frameBorder
of type DOMString
longDesc
of type DOMString
marginHeight
of type DOMString
marginWidth
of type DOMString
name
of type DOMString
target
attribute). See the name attribute definition in HTML 4.0.
noResize
of type boolean
scrolling
of type DOMString
src
of type DOMString
Inline subwindows. See the IFRAME element definition in HTML 4.0.
interface HTMLIFrameElement : HTMLElement { attribute DOMString align; attribute DOMString frameBorder; attribute DOMString height; attribute DOMString longDesc; attribute DOMString marginHeight; attribute DOMString marginWidth; attribute DOMString name; attribute DOMString scrolling; attribute DOMString src; attribute DOMString width; // Introduced in DOM Level 2: attribute Document contentDocument; };
align
of type DOMString
contentDocument
of type Document
, introduced in DOM Level 2null
otherwise.
frameBorder
of type DOMString
height
of type DOMString
longDesc
of type DOMString
marginHeight
of type DOMString
marginWidth
of type DOMString
name
of type DOMString
target
attribute). See the name attribute definition in HTML 4.0.
scrolling
of type DOMString
src
of type DOMString
width
of type DOMString
A document may have one or more "views" associated with it, e.g., a computed view on a document after applying a CSS stylesheet, or multiple presentations (e.g., HTML Frame) of the same document in a client. That is, a view is some alternate representation of, or a presentation of, and associated with, a source document.
A view may be static, reflecting the state of the document when the view was created, or dynamic, reflecting changes in the target document as they occur, subsequent to the view being created. This Level of the DOM specification makes no statement about these behaviors.
This section defines an AbstractView
interface which
provides a base interface from which all such views shall derive. It
defines an attribute which references the target document of the
AbstractView
. The only semantics of the AbstractView
defined here create an association between a view and its target document.
There are no subinterfaces of AbstractView
defined in the DOM
Level 2.
However, AbstractView
is defined in and used in this Level
in two places:
DocumentView
that has a default view
attribute associated with it. This default view is typically dependent on
the implementation (e.g., the browser frame rendering the document). The
default view can be used in order to identify and/or associate a view with
its target document (by testing object equality on the
AbstractView
or obtaining the DocumentView
attribute).UIEvent
typically occurs upon a view of a Document
(e.g., a mouse click on a browser frame rendering a particular Document
instance). A UIEvent
has an AbstractView
associated with it which identifies both the particular
(implementation-dependent) view in which the event occurs, and
the target document the UIEvent
is related to.The interfaces found within this section are not mandatory. A DOM
application can use the hasFeature
method of the
DOMImplementation
interface to determine whether they
are supported or not. The feature string for all the interfaces listed in
this section is "Views".
A base interface that all views shall derive from.
// Introduced in DOM Level 2: interface AbstractView { readonly attribute DocumentView document; };
document
of type DocumentView
, readonlyDocumentView
of which this is an
AbstractView
.
The DocumentView
interface is implemented by
Document
objects in DOM implementations supporting DOM
Views. It provides an attribute to retrieve the default view of a
document.
// Introduced in DOM Level 2: interface DocumentView { readonly attribute AbstractView defaultView; };
defaultView
of type AbstractView
, readonlyAbstractView
for this
Document
, or null
if none
available.
The DOM Level 2 Style Sheet interfaces are base interfaces used to represent any type of style sheet. The expectation is that DOM modules that represent a specific style sheet language may contain interfaces that derive from these interfaces.
A DOM application can use the hasFeature
method of the
DOMImplementation
interface to determine whether the
StyleSheets interfaces are supported or not. The feature string for the
fundamental interfaces listed in this section is "StyleSheets".
This set of interfaces represents the generic notion of style sheets.
The StyleSheet
interface is the abstract base interface for
any type of style sheet. It represents a single style sheet associated
with a structured document. In HTML, the StyleSheet interface represents
either an external style sheet, included via the HTML
LINK element, or an inline
STYLE element. In XML, this interface represents an external
style sheet, included via a
style sheet
processing instruction.
// Introduced in DOM Level 2: interface StyleSheet { readonly attribute DOMString type; attribute boolean disabled; readonly attribute Node ownerNode; readonly attribute StyleSheet parentStyleSheet; readonly attribute DOMString href; readonly attribute DOMString title; readonly attribute MediaList media; };
disabled
of type boolean
false
if the style sheet is applied to the document.
true
if it is not. Modifying this attribute may cause a
new resolution of style for the document. A stylesheet only applies if
both an appropriate medium definition is present and the disabled
attribute is false. So, if the media doesn't apply to the current user
agent, the disabled
attribute is ignored.
href
of type DOMString
, readonlynull
. See the
href
attribute definition for the LINK
element in HTML
4.0, and the href pseudo-attribute for the XML
style sheet processing
instruction.
media
of type MediaList
, readonlyownerNode
. If no media has been
specified, the MediaList
will be empty. See the
media
attribute definition for the LINK
element in
HTML 4.0, and the media pseudo-attribute for the XML
style sheet processing
instruction . Modifying the media list may cause a change to
the attribute disabled
.
ownerNode
of type Node
, readonlyLINK
or STYLE
element. For XML, it may be the linking processing instruction. For
style sheets that are included by other style sheets, the value of this
attribute is null
.
parentStyleSheet
of type StyleSheet
, readonlynull
.
title
of type DOMString
, readonlyownerNode
. See the
title
attribute definition for the LINK
element in HTML
4.0, and the title pseudo-attribute for the XML
style sheet processing
instruction.
type
of type DOMString
, readonlyownerNode
(see also
[ContentTypes]). Also see the
type attribute
definition for the LINK
element in HTML 4.0,
and the type pseudo-attribute for the XML
style sheet processing instruction.
The StyleSheetList
interface provides the
abstraction of an ordered collection of style sheets.
// Introduced in DOM Level 2: interface StyleSheetList { readonly attribute unsigned long length; StyleSheet item(in unsigned long index); };
length
of type unsigned long
, readonlyStyleSheets
in the list. The range of valid
child stylesheet indices is 0
to length-1
inclusive.
item
|
| Index into the collection |
The style sheet at the |
The MediaList
interface provides the abstraction of an
ordered collection of
media,
without defining or constraining how this collection is implemented. An
empty list is the same as a list that contains the medium
"all"
.
// Introduced in DOM Level 2: interface MediaList { attribute DOMString mediaText; // raises(DOMException) on setting readonly attribute unsigned long length; DOMString item(in unsigned long index); void delete(in DOMString oldMedium) raises(DOMException); void append(in DOMString newMedium) raises(DOMException); };
length
of type unsigned long
, readonly0
to length-1
inclusive.
mediaText
of type DOMString
SYNTAX_ERR: Raised if the specified string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this media list is readonly. |
append
newMedium
to the end of the list. If the
newMedium
is already used, it is first removed.
| The new medium to add. |
NO_MODIFICATION_ALLOWED_ERR: Raised if this list is readonly. |
delete
oldMedium
from the list.
| The medium to delete in the media list. |
NO_MODIFICATION_ALLOWED_ERR: Raised if this list is readonly.
NOT_FOUND_ERR: Raised if |
item
index
th in the list. If index
is
greater than or equal to the number of media in the list, this returns
null
.
|
| Index into the collection. |
The medium at the |
The LinkStyle
interface provides a mechanism by which a
style sheet can be retrieved from the node responsible for linking it
into a document. An instance of the LinkStyle
interface can
be obtained using binding-specific casting methods on an instance of a
linking node (HTMLLinkElement
, HTMLStyleElement
or ProcessingInstruction
in DOM Level 2).
// Introduced in DOM Level 2: interface LinkStyle { readonly attribute StyleSheet sheet; };
sheet
of type StyleSheet
, readonly
The DocumentStyle
interface provides a mechanism by which
the style sheets embedded in a document can be retrieved. The expectation
is that an instance of the DocumentStyle
interface can be
obtained by using binding-specific casting methods on an instance of the
Document
interface.
// Introduced in DOM Level 2: interface DocumentStyle { readonly attribute StyleSheetList styleSheets; };
styleSheets
of type StyleSheetList
, readonly
HTMLLinkElement
interface). The underlying style
sheet will be created after the element is inserted into the
document and both the href and the type attribute have been set
in a way indicating that the linked object is a style sheet.
HTMLStyLeElement
interface). The underlying style
sheet will be created after the element is inserted into the
document and the type attribute is set in a way indicating that
the element corresponds to a style sheet language interpreted
by the user agent.
The DOM Level 2 Cascading Style Sheets (CSS) interfaces are designed with the goal of exposing CSS constructs to object model consumers. Cascading Style Sheets is a declarative syntax for defining presentation rules, properties and ancillary constructs used to format and render Web documents. This document specifies a mechanism to programmatically access and modify the rich style and presentation control provided by CSS (specifically CSS level 2 [CSS2]). This augments CSS by providing a mechanism to dynamically control the inclusion and exclusion of individual style sheets, as well as manipulate CSS rules and properties.
The CSS interfaces are organized in a logical, rather than physical structure. A collection of all style sheets referenced by or embedded in the document is accessible on the document interface. Each item in this collection exposes the properties common to all style sheets referenced or embedded in HTML and XML documents; this interface is described in the Document Object Model StyleSheets. User style sheets are not accessible through this collection, in part due to potential privacy concerns (and certainly read-write issues).
For each CSS style sheet, an additional interface is exposed - the
CSSStyleSheet
interface. This interface allows access to
the collection of rules within a CSS style sheet and methods to modify
that collection. Interfaces are provided for each specific type of rule
in CSS2 (e.g. style declarations, @import
rules, or
@font-face
rules), as well as a shared generic
CSSRule
interface.
The most common type of rule is a style declaration. The
CSSStyleRule
interface that represents this type of rule
provides string access to the CSS selector of the rule, and access to the
property declarations through the CSSStyleDeclaration
interface.
Finally, an optional CSS2Properties
interface is described;
this interface (if implemented) provides shortcuts to the string
values of all the properties in CSS level 2.
All CSS objects in the DOM are "live", that is, a change in the style sheet is reflected in the computed and actual style.
A DOM application can use the hasFeature
method of the
DOMImplementation
interface to determine whether the CSS
interfaces are supported or not. The feature string for the CSS Model is
"CSS". The existence within an implementation of the extended interfaces
can also be queried using the hasFeature
method.
The interfaces within this section are considered fundamental, and must be supported by all conforming DOM implementations. These interfaces represent CSS style sheets specifically.
The CSSStyleSheet
interface is a concrete interface used
to represent a CSS style sheet i.e., a style sheet whose content type
is "text/css".
// Introduced in DOM Level 2: interface CSSStyleSheet : stylesheets::StyleSheet { readonly attribute CSSRule ownerRule; readonly attribute CSSRuleList cssRules; unsigned long insertRule(in DOMString rule, in unsigned long index) raises(DOMException); void deleteRule(in unsigned long index) raises(DOMException); };
cssRules
of type CSSRuleList
, readonly
ownerRule
of type CSSRule
, readonly@import
rule, the
ownerRule
attribute will contain the
CSSImportRule
. In that case, the ownerNode
attribute in the StyleSheet
interface will be
null
. If the style sheet comes from an element or a
processing instruction, the ownerRule
attribute will be
null
and the ownerNode
attribute will contain
the Node
.
deleteRule
|
| The index within the style sheet's rule list of the rule to remove. |
INDEX_SIZE_ERR: Raised if the specified index does not correspond to a rule in the style sheet's rule list. NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is readonly. |
insertRule
| The parsable text representing the rule. For rule sets this contains both the selector and the style declaration. For at-rules, this specifies both the at-identifier and the rule content. | |||
|
| The index within the style sheet's rule list of the rule before which to insert the specified rule. If the specified index is equal to the length of the style sheet's rule collection, the rule will be added to the end of the style sheet. |
|
The index within the style sheet's rule collection of the newly inserted rule. |
HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted
at the specified index e.g. if an INDEX_SIZE_ERR: Raised if the specified index is not a valid insertion point. NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is readonly. SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable. |
The CSSRuleList
interface provides the
abstraction of an ordered collection of CSS rules.
// Introduced in DOM Level 2: interface CSSRuleList { readonly attribute unsigned long length; CSSRule item(in unsigned long index); };
item
|
| Index into the collection |
The style rule at the |
The CSSRule
interface is the abstract base interface for any
type of CSS
statement.
This includes both
rule sets
and
at-rules. An
implementation is expected to preserve all rules specified in a CSS style
sheet, even if the rule is not recognized by the parser. Unrecognized
rules are represented using the CSSUnknownRule
interface.
// Introduced in DOM Level 2: interface CSSRule { // RuleType const unsigned short UNKNOWN_RULE = 0; const unsigned short STYLE_RULE = 1; const unsigned short CHARSET_RULE = 2; const unsigned short IMPORT_RULE = 3; const unsigned short MEDIA_RULE = 4; const unsigned short FONT_FACE_RULE = 5; const unsigned short PAGE_RULE = 6; readonly attribute unsigned short type; attribute DOMString cssText; // raises(DOMException) on setting readonly attribute CSSStyleSheet parentStyleSheet; readonly attribute CSSRule parentRule; };
An integer indicating which type of rule this is.
CHARSET_RULE |
The rule is a CSSCharsetRule . |
FONT_FACE_RULE |
The rule is a CSSFontFaceRule . |
IMPORT_RULE |
The rule is a CSSImportRule . |
MEDIA_RULE |
The rule is a CSSMediaRule . |
PAGE_RULE |
The rule is a CSSPageRule . |
STYLE_RULE |
The rule is a CSSStyleRule . |
UNKNOWN_RULE |
The rule is a CSSUnknownRule . |
cssText
of type DOMString
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable. INVALID_MODIFICATION_ERR: Raised if the specified CSS string value represents a different type of rule than the current one. HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at this point in the style sheet. NO_MODIFICATION_ALLOWED_ERR: Raised if the rule is readonly. |
parentRule
of type CSSRule
, readonlynull
.
parentStyleSheet
of type CSSStyleSheet
, readonly
type
of type unsigned short
, readonlyCSSRule
interface to the specific derived
interface implied by the type
.
The CSSStyleRule
interface represents a single
rule set
in a CSS style sheet.
// Introduced in DOM Level 2: interface CSSStyleRule : CSSRule { attribute DOMString selectorText; // raises(DOMException) on setting readonly attribute CSSStyleDeclaration style; };
selectorText
of type DOMString
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this rule is readonly. |
style
of type CSSStyleDeclaration
, readonly
The CSSMediaRule
interface represents a
@media
rule in a CSS style sheet. A @media
rule can be
used to delimit style rules for specific media types.
// Introduced in DOM Level 2: interface CSSMediaRule : CSSRule { readonly attribute stylesheets::MediaList media; readonly attribute CSSRuleList cssRules; unsigned long insertRule(in DOMString rule, in unsigned long index) raises(DOMException); void deleteRule(in unsigned long index) raises(DOMException); };
cssRules
of type CSSRuleList
, readonly
media
of type stylesheets::MediaList
, readonly
deleteRule
|
| The index within the media block's rule collection of the rule to remove. |
INDEX_SIZE_ERR: Raised if the specified index does not correspond to a rule in the media rule list. NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is readonly. |
insertRule
| The parsable text representing the rule. For rule sets this contains both the selector and the style declaration. For at-rules, this specifies both the at-identifier and the rule content. | |||
|
| The index within the media block's rule collection of the rule before which to insert the specified rule. If the specified index is equal to the length of the media blocks's rule collection, the rule will be added to the end of the media block. |
|
The index within the media block's rule collection of the newly inserted rule. |
HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted
at the specified index, e.g., if an INDEX_SIZE_ERR: Raised if the specified index is not a valid insertion point. NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is readonly. SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable. |
The CSSFontFaceRule
interface represents a
@font-face
rule in a CSS style sheet. The @font-face
rule
is used to hold a set of font descriptions.
// Introduced in DOM Level 2: interface CSSFontFaceRule : CSSRule { readonly attribute CSSStyleDeclaration style; };
style
of type CSSStyleDeclaration
, readonly
The CSSPageRule
interface represents a
@page
rule within a CSS style sheet. The @page
rule is
used to specify the dimensions, orientation, margins, etc. of a page box
for paged media.
// Introduced in DOM Level 2: interface CSSPageRule : CSSRule { attribute DOMString selectorText; // raises(DOMException) on setting readonly attribute CSSStyleDeclaration style; };
selectorText
of type DOMString
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this rule is readonly. |
style
of type CSSStyleDeclaration
, readonly
The CSSImportRule
interface represents a
@import
rule within a CSS style sheet. The @import
rule is
used to import style rules from other style sheets.
// Introduced in DOM Level 2: interface CSSImportRule : CSSRule { readonly attribute DOMString href; readonly attribute stylesheets::MediaList media; readonly attribute CSSStyleSheet styleSheet; };
href
of type DOMString
, readonly"url(...)"
specifier around the URI.
media
of type stylesheets::MediaList
, readonly
styleSheet
of type CSSStyleSheet
, readonlynull
if the style sheet has not
yet been loaded or if it will not be loaded (e.g. if the style sheet is
for a media type not supported by the user agent).
The CSSCharsetRule
interface represents a
@charset
rule in a CSS style sheet. The value of the
encoding
attribute does not at all affect the encoding of
text data in the DOM objects; this encoding is always UTF-16. After a
stylesheet is loaded, the value of the encoding
attribute is
the value found in the @charset
rule. If there was no
@charset
in the original document, then no
CSSCharsetRule
is created. The value of the
encoding
attribute may also be used as a hint for the
encoding used on serialization of the style sheet.
The value of the
@charset
rule (and therefore of the CSSCharsetRule
) may
not correspond to the encoding the document actually came in; character
encoding information e.g. in an HTTP header, has priority (see
http://www.w3.org/TR/1998/REC-CSS2-19980512/syndata.html#x66) but is
not reflected in the CSSCharsetRule
.
// Introduced in DOM Level 2: interface CSSCharsetRule : CSSRule { attribute DOMString encoding; // raises(DOMException) on setting };
The CSSUnknownRule
interface represents an at-rule not
supported by this user agent.
// Introduced in DOM Level 2: interface CSSUnknownRule : CSSRule { };
The CSSStyleDeclaration
interface represents a single
CSS declaration block. This interface may be used to determine the style properties
currently set in a block or to set style properties explicitly within
the block.
While an implementation may not recognize all CSS properties within
a CSS declaration block, it is expected to provide access to all specified
properties through the CSSStyleDeclaration
interface.
Furthermore, implementations that support a specific level of CSS
should correctly handle
CSS shorthand properties for that level. For a further
discussion of shorthand properties, see the CSS2Properties
interface.
// Introduced in DOM Level 2: interface CSSStyleDeclaration { attribute DOMString cssText; // raises(DOMException) on setting DOMString getPropertyValue(in DOMString propertyName); CSSValue getPropertyCSSValue(in DOMString propertyName); DOMString removeProperty(in DOMString propertyName) raises(DOMException); DOMString getPropertyPriority(in DOMString propertyName); void setProperty(in DOMString propertyName, in DOMString value, in DOMString priority) raises(DOMException); readonly attribute unsigned long length; DOMString item(in unsigned long index); readonly attribute CSSRule parentRule; };
cssText
of type DOMString
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly or a property is readonly. |
length
of type unsigned long
, readonly
parentRule
of type CSSRule
, readonlynull
if this CSSStyleDeclaration
is not attached to a
CSSRule
.
getPropertyCSSValue
null
if the property is a
shorthand property. Shorthand
property values can only be accessed and modified as strings, using
the getPropertyValue
and setProperty
methods.
| The name of the CSS property. See the CSS property index. |
Returns the value of the property if it has been explicitly set for
this declaration block. Returns |
getPropertyPriority
"important"
qualifier) if the property
has been explicitly set in this declaration block.
| The name of the CSS property. See the CSS property index. |
A string representing the priority (e.g. |
getPropertyValue
| The name of the CSS property. See the CSS property index. |
Returns the value of the property if it has been explicitly set for this declaration block. Returns the empty string if the property has not been set. |
item
|
| Index of the property name to retrieve. |
The name of the property at this ordinal position. The empty string if no property exists at this position. |
removeProperty
| The name of the CSS property. See the CSS property index. |
Returns the value of the property if it has been explicitly set for this declaration block. Returns the empty string if the property has not been set or the property name does not correspond to a valid CSS2 property. |
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly or the property is readonly. |
setProperty
| The name of the CSS property. See the CSS property index. | |||
| The new value of the property. | |||
|
The new priority of the property (e.g. |
SYNTAX_ERR: Raised if the specified value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly or the property is readonly. |
The CSSValue
interface represents a simple or a complex
value. A CSSValue
object only occurs in a context of a CSS
property.
// Introduced in DOM Level 2: interface CSSValue { // UnitTypes const unsigned short CSS_INHERIT = 0; const unsigned short CSS_PRIMITIVE_VALUE = 1; const unsigned short CSS_VALUE_LIST = 2; const unsigned short CSS_CUSTOM = 3; attribute DOMString cssText; // raises(DOMException) on setting readonly attribute unsigned short valueType; };
An integer indicating which type of unit applies to the value.
CSS_CUSTOM | The value is a custom value. |
CSS_INHERIT | The value is inherited. |
CSS_PRIMITIVE_VALUE |
The value is a primitive value and an instance of the
CSSPrimitiveValue interface can be obtained by using
binding-specific casting methods on this instance of the
CSSValue interface. |
CSS_VALUE_LIST |
The value is a list CSSValue . |
cssText
of type DOMString
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error (according to the attached property) or is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this value is readonly. |
valueType
of type unsigned short
, readonly
The CSSPrimitiveValue
interface represents a single
CSS
value. This interface may be used to determine the value of a
specific style property currently set in a block or to set a specific
style property explicitly within the block. An instance of this interface
can be obtained from the getPropertyCSSValue
method of the
CSSStyleDeclaration
interface. A
CSSPrimitiveValue
object only occurs in a context of a CSS
property.
Conversions are allowed between absolute values (from millimeters to
centimeters, from degrees to radians, and so on) but not between relative
values. (For example, a pixel value cannot be converted to a centimeter
value.) Percentage values can't be converted since they are relative to
the parent value (or another property value). There is one exception for
color percentage values: since a color percentage value is relative to
the range 0-255, a color percentage value can be converted to a number;
(see also the RGBColor
interface).
// Introduced in DOM Level 2: interface CSSPrimitiveValue : CSSValue { // UnitTypes const unsigned short CSS_UNKNOWN = 0; const unsigned short CSS_NUMBER = 1; const unsigned short CSS_PERCENTAGE = 2; const unsigned short CSS_EMS = 3; const unsigned short CSS_EXS = 4; const unsigned short CSS_PX = 5; const unsigned short CSS_CM = 6; const unsigned short CSS_MM = 7; const unsigned short CSS_IN = 8; const unsigned short CSS_PT = 9; const unsigned short CSS_PC = 10; const unsigned short CSS_DEG = 11; const unsigned short CSS_RAD = 12; const unsigned short CSS_GRAD = 13; const unsigned short CSS_MS = 14; const unsigned short CSS_S = 15; const unsigned short CSS_HZ = 16; const unsigned short CSS_KHZ = 17; const unsigned short CSS_DIMENSION = 18; const unsigned short CSS_STRING = 19; const unsigned short CSS_URI = 20; const unsigned short CSS_IDENT = 21; const unsigned short CSS_ATTR = 22; const unsigned short CSS_COUNTER = 23; const unsigned short CSS_RECT = 24; const unsigned short CSS_RGBCOLOR = 25; readonly attribute unsigned short primitiveType; void setFloatValue(in unsigned short unitType, in float floatValue) raises(DOMException); float getFloatValue(in unsigned short unitType) raises(DOMException); void setStringValue(in unsigned short stringType, in DOMString stringValue) raises(DOMException); DOMString getStringValue() raises(DOMException); Counter getCounterValue() raises(DOMException); Rect getRectValue() raises(DOMException); RGBColor getRGBColorValue() raises(DOMException); };
An integer indicating which type of unit applies to the value.
CSS_ATTR |
The value is a
attribute
function. The value can be obtained by using the getStringValue
method. |
CSS_CM |
The value is a
length
(cm). The value can be obtained by using the getFloatValue
method. |
CSS_COUNTER |
The value is a
counter or
counters function. The value can be obtained by using the
getCounterValue method. |
CSS_DEG |
The value is an
angle
(deg). The value can be obtained by using the getFloatValue
method. |
CSS_DIMENSION |
The value is a number with an unknown dimension.
The value can be obtained by using the getFloatValue method. |
CSS_EMS |
The value is a
length
(ems). The value can be obtained by using the getFloatValue
method. |
CSS_EXS |
The value is a
length
(exs). The value can be obtained by using the getFloatValue
method. |
CSS_GRAD |
The value is an
angle
(grad). The value can be obtained by using the getFloatValue
method. |
CSS_HZ |
The value is a
frequency
(Hz). The value can be obtained by using the getFloatValue
method. |
CSS_IDENT |
The value is an
identifier.
The value can be obtained by using the getStringValue method. |
CSS_IN |
The value is a
length
(in). The value can be obtained by using the getFloatValue
method. |
CSS_KHZ |
The value is a
frequency
(kHz). The value can be obtained by using the getFloatValue
method. |
CSS_MM |
The value is a
length
(mm). The value can be obtained by using the getFloatValue
method. |
CSS_MS |
The value is a
time
(ms). The value can be obtained by using the getFloatValue
method. |
CSS_NUMBER |
The value is a simple
number.
The value can be obtained by using the getFloatValue method. |
CSS_PC |
The value is a
length
(pc). The value can be obtained by using the getFloatValue
method. |
CSS_PERCENTAGE |
The value is a
percentage.
The value can be obtained by using the getFloatValue method. |
CSS_PT |
The value is a
length
(pt). The value can be obtained by using the getFloatValue
method. |
CSS_PX |
The value is a
length
(px). The value can be obtained by using the getFloatValue
method. |
CSS_RAD |
The value is an
angle
(rad). The value can be obtained by using the getFloatValue
method. |
CSS_RECT |
The value is a
rect
function. The value can be obtained by using the getRectValue
method. |
CSS_RGBCOLOR |
The value is a
RGB
color. The value can be obtained by using the getRGBColorValue
method. |
CSS_S |
The value is a
time (s).
The value can be obtained by using the getFloatValue method. |
CSS_STRING |
The value is a
STRING.
The value can be obtained by using the getStringValue method. |
CSS_UNKNOWN |
The value is not a recognized CSS2 value. The value can only be
obtained by using the cssText attribute. |
CSS_URI |
The value is a
URI.
The value can be obtained by using the getStringValue method. |
primitiveType
of type unsigned short
, readonly
getCounterValue
DOMException
is
raised. Modification to the corresponding style property can be
achieved using the Counter
interface.
The Counter value. |
INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a
Counter value (e.g. this is not |
getFloatValue
DOMException
is raised.
|
|
A unit code to get the float value. The unit code can only be a
float unit type (i.e. |
|
The float value in the specified unit. |
INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a float value or if the float value can't be converted into the specified unit. |
getRGBColorValue
DOMException
is
raised. Modification to the corresponding style property can be
achieved using the RGBColor
interface.
the RGB color value. |
INVALID_ACCESS_ERR: Raised if the attached property can't return a
RGB color value (e.g. this is not |
getRectValue
DOMException
is
raised. Modification to the corresponding style property can be
achieved using the Rect
interface.
The Rect value. |
INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Rect
value. (e.g. this is not |
getStringValue
DOMException
is raised.
Note: Some properties (like 'font-family' or 'voice-family') convert a whitespace separated list of idents to a string.
The string value in the current unit. The current
|
INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string value. |
setFloatValue
DOMException
will
be raised.
|
|
A unit code as defined above. The unit code can only be a float
unit type (i.e. | ||
|
| The new float value. |
INVALID_ACCESS_ERR: Raised if the attached property doesn't support the float value or the unit type. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
setStringValue
DOMException
will be raised.
|
|
A string code as defined above. The string code can only be a
string unit type (i.e. | ||
| The new string value. |
INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string value or if the string value can't be converted into the specified unit. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
The CSSValueList
interface provides the abstraction of an
ordered collection of CSS values.
Some properties allow an empty list into their syntax. In that case,
these properties take the none
identifier. So, an empty list
means that the property has the value none
.
// Introduced in DOM Level 2: interface CSSValueList : CSSValue { readonly attribute unsigned long length; CSSValue item(in unsigned long index); };
item
|
| Index into the collection. |
The style rule at the |
The RGBColor
interface is used to represent any
RGB
color value. This interface reflects the values in the
underlying style property. Hence, modifications made to the
CSSPrimitiveValue
objects modify the style property.
A specified RGB color is not clipped (even if the number is outside the range 0-255 or 0%-100%). A computed RGB color is clipped depending on the device.
Even if a style sheet can only contain an integer for a color value, the internal storage of this integer is a float, and this can be used as a float in the specified or the computed style.
A color percentage value can always be converted to a number and vice versa.
// Introduced in DOM Level 2: interface RGBColor { readonly attribute CSSPrimitiveValue red; readonly attribute CSSPrimitiveValue green; readonly attribute CSSPrimitiveValue blue; };
blue
of type CSSPrimitiveValue
, readonly
green
of type CSSPrimitiveValue
, readonly
red
of type CSSPrimitiveValue
, readonly
The Rect
interface is used to represent any
rect
value. This interface reflects the values in the underlying style
property. Hence, modifications made to the CSSPrimitiveValue
objects modify the style property.
// Introduced in DOM Level 2: interface Rect { readonly attribute CSSPrimitiveValue top; readonly attribute CSSPrimitiveValue right; readonly attribute CSSPrimitiveValue bottom; readonly attribute CSSPrimitiveValue left; };
bottom
of type CSSPrimitiveValue
, readonly
left
of type CSSPrimitiveValue
, readonly
right
of type CSSPrimitiveValue
, readonly
top
of type CSSPrimitiveValue
, readonly
The Counter
interface is used to represent any
counter or
counters function value. This interface reflects the values in
the underlying style property. Hence, modifications made to the
CSSPrimitiveValue
objects modify the style property.
// Introduced in DOM Level 2: interface Counter { readonly attribute DOMString identifier; readonly attribute DOMString listStyle; readonly attribute DOMString separator; };
This interface represents a CSS view. The getComputedStyle
method provides a read only access to the
computed values of
an element.
The expectation is that an instance of the ViewCSS
interface can be obtained by using binding-specific casting methods on an
instance of the View
interface.
Since a computed style is related to an Element
node, if
this element is removed from the document, the associated
CSSStyleDeclaration
and CSSValue
related to
this declaration are no longer valid.
// Introduced in DOM Level 2: interface ViewCSS : views::AbstractView { CSSStyleDeclaration getComputedStyle(in Element elt, in DOMString pseudoElt); };
getComputedStyle
The computed style. The |
This interface represents a document with a CSS view.
The getOverrideStyle
method provides a mechanism through
which a DOM author could effect immediate change to the style of an
element without modifying the explicitly linked style sheets of a
document or the inline style of elements in the style sheets. This style
sheet comes after the author style sheet in the cascade algorithm and is
called override style sheet. The override style sheet takes
precedence over author style sheets. An "!important" declaration still
takes precedence over a normal declaration. Override, author, and user
style sheets all may contain "!important" declarations. User "!important"
rules take precedence over both override and author "!important" rules,
and override "!important" rules take precedence over author "!important"
rules.
The expectation is that an instance of the DocumentCSS
interface can be obtained by using binding-specific casting methods on an
instance of the Document
interface.
// Introduced in DOM Level 2: interface DocumentCSS : stylesheets::DocumentStyle { CSSStyleDeclaration getOverrideStyle(in Element elt, in DOMString pseudoElt); };
getOverrideStyle
The override style declaration. |
This interface allows the DOM user to create a CSSStyleSheet
outside the context of a document. There is no way to associate the new
CSSStyleSheet
with a document in DOM Level 2.
// Introduced in DOM Level 2: interface DOMImplementationCSS : DOMImplementation { CSSStyleSheet createCSSStyleSheet(in DOMString title, in DOMString media); };
createCSSStyleSheet
CSSStyleSheet
.
| The advisory title. See also the Style Sheet Interfaces section. | |||
| The comma-separated list of media associated with the new style sheet. See also the Style Sheet Interfaces section. |
A new CSS style sheet. |
Inline style information attached to elements is exposed through the
style
attribute. This represents the contents of the
STYLE
attribute for HTML elements (or elements in other schemas or DTDs which use
the STYLE attribute in the same way).
// Introduced in DOM Level 2: interface ElementCSSInlineStyle { readonly attribute CSSStyleDeclaration style; };
style
of type CSSStyleDeclaration
, readonly
The interfaces found within this section are not mandatory. A DOM
application can use the hasFeature
method of the
DOMImplementation
interface to determine whether they are
supported or not. The feature string for all the extended interfaces
listed in this section is "CSS2".
The following table specifies the type of CSSValue
used
to represent each property that can be specified in a
CSSStyleDeclaration
found in a CSSStyleRule
for
a CSS Level 2 style sheet. The expectation is that the
CSSValue
returned from the getPropertyCSSValue
method on the CSSStyleDeclaration
interface can be
cast down, using binding-specific casting methods, to the specific
derived interface.
For properties that are represented by a custom interface (the
valueType
of the CSSValue
is
CSS_CUSTOM
), the name of the derived interface is specified in
the table.
For properties that consist of lists of values (the valueType
of the CSSValue
is CSS_VALUE_LIST
), the
derived interface is CSSValueList
. For all other
properties (the valueType
of the CSSValue
is CSS_PRIMITIVE_VALUE
), the
derived interface is CSSPrimitiveValue
.
Property Name | Representation |
azimuth | CSS2Azimuth |
background | null |
background-attachment | ident |
background-color | rgbcolor, ident |
background-image | uri, ident |
background-position | CSS2BackgroundPosition |
background-repeat | ident |
border | null |
border-collapse | ident |
border-color | null |
border-spacing | CSS2BorderSpacing |
border-style | null |
border-top, border-right, border-bottom, border-left | null |
border-top-color, border-right-color, border-bottom-color, border-left-color | rgbcolor, ident |
border-top-style, border-right-style, border-bottom-style, border-left-style | ident |
border-top-width, border-right-width, border-bottom-width, border-left-width | length, ident |
border-width | null |
bottom | length, percentage, ident |
caption-side | ident |
clear | ident |
clip | rect, ident |
color | rgbcolor, ident |
content | list of string, uri, counter, attr, ident |
counter-increment | list of CSS2CounterIncrement |
counter-reset | list of CSS2CounterReset |
cue | null |
cue-after, cue-before | uri, ident |
cursor | CSS2Cursor |
direction | ident |
display | ident |
elevation | angle, ident |
empty-cells | ident |
float | ident |
font | null |
font-family | list of strings and idents |
font-size | ident, length, percentage |
font-size-adjust | number, ident |
font-stretch | ident |
font-style | ident |
font-variant | ident |
font-weight | ident |
height | length, percentage, ident |
left | length, percentage, ident |
letter-spacing | ident, length |
line-height | ident, length, percentage, number |
list-style | null |
list-style-image | uri, ident |
list-style-position | ident |
list-style-type | ident |
margin | null |
margin-top, margin-right, margin-bottom, margin-left | length, percentage, ident |
marker-offset | length, ident |
max-height | length, percentage, ident |
max-width | length, percentage, ident |
min-height | length, percentage, ident |
min-width | length, percentage, ident |
orphans | number |
outline | null |
outline-color | rgbcolor, ident |
outline-style | ident |
outline-width | length, ident |
overflow | ident |
padding | null |
padding-top, padding-right, padding-bottom, padding-left | length, percentage |
page | ident |
page-break-after | ident |
page-break-before | ident |
page-break-inside | ident |
pause | null |
pause-after, pause-before | time, percentage |
pitch | frequency, identifier |
pitch-range | number |
play-during | CSS2PlayDuring |
position | ident |
quotes | list of string or ident |
richness | number |
right | length, percentage, ident |
speak | ident |
speak-header | ident |
speak-numeral | ident |
speak-punctuation | ident |
speech-rate | number, ident |
stress | number |
table-layout | ident |
text-align | ident, string |
text-decoration | list of ident |
text-indent | length, percentage |
text-shadow | list of CSS2TextShadow |
text-transform | ident |
top | length, percentage, ident |
unicode-bidi | ident |
vertical-align | ident, percentage, length |
visibility | ident |
voice-family | list of strings and idents |
volume | number, percentage, ident |
white-space | ident |
widows | number |
width | length, percentage, ident |
word-spacing | length, ident |
z-index | ident, number |
The CSS2Azimuth
interface represents the
azimuth
CSS Level 2 property.
// Introduced in DOM Level 2: interface CSS2Azimuth : CSSValue { readonly attribute unsigned short azimuthType; readonly attribute DOMString identifier; readonly attribute boolean behind; void setAngleValue(in unsigned short uType, in float fValue) raises(DOMException); float getAngleValue(in unsigned short uType) raises(DOMException); void setIdentifier(in DOMString ident, in boolean b) raises(DOMException); };
azimuthType
of type unsigned short
, readonlyCSSValue
. It would be one of CSS_DEG
,
CSS_RAD
, CSS_GRAD
or
CSS_IDENT
.
behind
of type boolean
, readonlybehind
indicates whether the behind identifier has been
set.
identifier
of type DOMString
, readonlyazimuthType
is CSS_IDENT
,
identifier
contains one of left-side, far-left, left,
center-left, center, center-right, right, far-right, right-side,
leftwards, rightwards. The empty string if none is set.
getAngleValue
|
| The unit type can be only an angle unit type
( |
|
The float value. |
INVALID_ACCESS_ERR: Raised if the unit type is invalid. |
setAngleValue
|
| The unitType could only be one of | ||
|
| The new float value of the angle. |
INVALID_ACCESS_ERR: Raised if the unit type is invalid. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
setIdentifier
azimuthType
is set
to CSS_IDENT
| The new identifier. If the identifier is "leftwards" or "rightward", the behind attribute is ignored. | |||
|
| The new value for behind. |
SYNTAX_ERR: Raised if the specified NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
The CSS2BackgroundPosition
interface represents the
background-position
CSS Level 2 property.
// Introduced in DOM Level 2: interface CSS2BackgroundPosition : CSSValue { readonly attribute unsigned short horizontalType; readonly attribute unsigned short verticalType; readonly attribute DOMString horizontalIdentifier; readonly attribute DOMString verticalIdentifier; float getHorizontalPosition(in float hType) raises(DOMException); float getVerticalPosition(in float vType) raises(DOMException); void setHorizontalPosition(in unsigned short hType, in float value) raises(DOMException); void setVerticalPosition(in unsigned short vType, in float value) raises(DOMException); void setPositionIdentifier(in DOMString hIdentifier, in DOMString vIdentifier) raises(DOMException); };
horizontalIdentifier
of type DOMString
, readonlyhorizontalType
is CSS_IDENT
or
CSS_INHERIT
, this attribute contains the string
representation of the ident, otherwise it contains an empty string.
horizontalType
of type unsigned short
, readonlyCSS_PERCENTAGE
, CSS_EMS
,
CSS_EXS
, CSS_PX
, CSS_CM
,
CSS_MM
, CSS_IN
, CSS_PT
,
CSS_PC
or CSS_IDENT
. If one of horizontal or
vertical is CSS_IDENT
, it's guaranteed that the other is
the same.
verticalIdentifier
of type DOMString
, readonlyverticalType
is CSS_IDENT
or
CSS_INHERIT
, this attribute contains the string
representation of the ident, otherwise it contains an empty string. The
value is "center"
if only the horizontalIdentifier has
been set.
verticalType
of type unsigned short
, readonlyCSS_PERCENTAGE
,
CSS_EMS
, CSS_EXS
, CSS_PX
,
CSS_CM
, CSS_MM
, CSS_IN
,
CSS_PT
, CSS_PC
, CSS_IDENT
,
CSS_INHERIT
. If one of horizontal or vertical is
CSS_IDENT
or CSS_INHERIT
, it's guaranteed
that the other is the same.
getHorizontalPosition
horizontalPosition
represents a length or a percentage. If
the float doesn't contain a float value or can't be converted into the
specified unit, a DOMException
is raised.
|
| The horizontal unit. |
|
The float value. |
INVALID_ACCESS_ERR: Raised if the property doesn't contain a float or the value can't be converted. |
getVerticalPosition
verticalPosition
represents a length or a percentage. If the
float doesn't contain a float value or can't be converted into the
specified unit, a DOMException
is raised. The value is
50%
if only the horizontal value has been specified.
|
| The vertical unit. |
|
The float value. |
INVALID_ACCESS_ERR: Raised if the property doesn't contain a float or the value can't be converted. |
setHorizontalPosition
50%
.
|
| The specified unit (a length or a percentage). | ||
|
| The new value. |
INVALID_ACCESS_ERR: Raised if the specified unit is not a length or a percentage. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
setPositionIdentifier
"center"
).
SYNTAX_ERR: Raised if the identifiers have a syntax error and are unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
setVerticalPosition
50%
.
|
| The specified unit (a length or a percentage). | ||
|
| The new value. |
INVALID_ACCESS_ERR: Raised if the specified unit is not a length or a percentage. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
The CSS2BorderSpacing
interface represents the
border-spacing
CSS Level 2 property.
// Introduced in DOM Level 2: interface CSS2BorderSpacing : CSSValue { readonly attribute unsigned short horizontalType; readonly attribute unsigned short verticalType; float getHorizontalSpacing(in float hType) raises(DOMException); float getVerticalSpacing(in float vType) raises(DOMException); void setHorizontalSpacing(in unsigned short hType, in float value) raises(DOMException); void setVerticalSpacing(in unsigned short vType, in float value) raises(DOMException); };
horizontalType
of type unsigned short
, readonlyCSSValue
. It would be one of CSS_EMS
,
CSS_EXS
, CSS_PX
, CSS_CM
,
CSS_MM
, CSS_IN
, CSS_PT
or
CSS_PC
.
verticalType
of type unsigned short
, readonlyCSSValue
. It would be one of CSS_EMS
,
CSS_EXS
, CSS_PX
, CSS_CM
,
CSS_MM
, CSS_IN
, CSS_PT
,
CSS_PC
or CSS_INHERIT
.
getHorizontalSpacing
horizontalSpacing
represents a length. If the float doesn't
contain a float value or can't be converted into the specified unit, a
DOMException
is raised.
|
| The horizontal unit. |
|
The float value. |
INVALID_ACCESS_ERR: Raised if the property doesn't contain a float or the value can't be converted. |
getVerticalSpacing
verticalSpacing
represents a length. If the float doesn't
contain a float value or can't be converted into the specified unit, a
DOMException
is raised. The value is 0
if only
the horizontal value has been specified.
|
| The vertical unit. |
|
The float value. |
INVALID_ACCESS_ERR: Raised if the property doesn't contain a float or the value can't be converted. |
setHorizontalSpacing
0
.
|
| The horizontal unit. | ||
|
| The new value. |
INVALID_ACCESS_ERR: Raised if the specified unit is not a length. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
setVerticalSpacing
0
.
|
| The vertical unit. | ||
|
| The new value. |
INVALID_ACCESS_ERR: Raised if the specified unit is not a length or a percentage. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
The CSS2CounterReset
interface represents a simple value
for the
counter-reset
CSS Level 2 property.
// Introduced in DOM Level 2: interface CSS2CounterReset : CSSValue { attribute DOMString identifier; // raises(DOMException) on setting attribute short reset; // raises(DOMException) on setting };
identifier
of type DOMString
SYNTAX_ERR: Raised if the specified identifier has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is readonly. |
reset
of type short
NO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is readonly. |
The CSS2CounterIncrement
interface represents a simple value
for the
counter-increment
CSS Level 2 property.
// Introduced in DOM Level 2: interface CSS2CounterIncrement : CSSValue { attribute DOMString identifier; // raises(DOMException) on setting attribute short increment; // raises(DOMException) on setting };
identifier
of type DOMString
SYNTAX_ERR: Raised if the specified identifier has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is readonly. |
increment
of type short
NO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is readonly. |
The CSS2Cursor
interface represents the
cursor
CSS Level 2 property.
// Introduced in DOM Level 2: interface CSS2Cursor : CSSValue { readonly attribute CSSValueList uris; attribute DOMString predefinedCursor; // raises(DOMException) on setting };
predefinedCursor
of type DOMString
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly. |
uris
of type CSSValueList
, readonlyuris
represents the list of URIs (CSS_URI
)
on the cursor property. The list can be empty.
The CSS2PlayDuring
interface represents the
play-during
CSS Level 2 property.
// Introduced in DOM Level 2: interface CSS2PlayDuring : CSSValue { readonly attribute unsigned short playDuringType; attribute DOMString playDuringIdentifier; // raises(DOMException) on setting attribute DOMString uri; // raises(DOMException) on setting attribute boolean mix; // raises(DOMException) on setting attribute boolean repeat; // raises(DOMException) on setting };
mix
of type boolean
true
if the sound should be mixed. It will be ignored if
the attribute doesn't contain a uri
.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly. |
playDuringIdentifier
of type DOMString
"inherit"
, "auto"
,
"none"
or the empty string if the
playDuringType
is CSS_UNKNOWN
. On setting, it
will set the uri
to the empty string and mix
and repeat
to false
.
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly. |
playDuringType
of type unsigned short
, readonlyCSSvalue
. It would be one of CSS_UNKNOWN
or
CSS_IDENT
.
repeat
of type boolean
true
if the sound should be repeated. It will be ignored
if the attribute doesn't contain a uri
.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly. |
uri
of type DOMString
uri
. It will set the
playDuringType
attribute to CSS_UNKNOWN
.
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly. |
The CSS2TextShadow
interface represents a simple value for
the
text-shadow
CSS Level 2 property.
// Introduced in DOM Level 2: interface CSS2TextShadow { readonly attribute CSSValue color; readonly attribute CSSValue horizontal; readonly attribute CSSValue vertical; readonly attribute CSSValue blur; };
blur
of type CSSValue
, readonly0
if no
length has been specified.
color
of type CSSValue
, readonly
horizontal
of type CSSValue
, readonly0
if no
length has been specified.
vertical
of type CSSValue
, readonly0
if no
length has been specified.
The following table specifies the type of CSSValue
used
to represent each descriptor that can be specified in a
CSSStyleDeclaration
found in a CSSFontFaceRule
for a CSS Level 2 style sheet.
Property Name | Representation |
font-family | list of strings and idents |
font-style | list of idents |
font-variant | list of idents |
font-weight | list of idents |
font-stretch | list of idents |
font-size | list of lengths or ident |
unicode-range | list of strings. Example: "U+370-3FF", "U+1F??" |
units-per-em | number |
src | list of CSS2FontFaceSrc |
panose-1 | list of integers |
stemv | number |
stemh | number |
slope | number |
cap-height | number |
x-height | number |
ascent | number |
descent | number |
widths | list of CSS2FontFaceWidths |
bbox | list of numbers |
definition-src | uri |
baseline | number |
centerline | number |
mathline | number |
topline | number |
The CSS2FontFaceSrc
interface represents the
src
CSS Level 2 descriptor.
// Introduced in DOM Level 2: interface CSS2FontFaceSrc { attribute DOMString uri; // raises(DOMException) on setting readonly attribute CSSValueList format; attribute DOMString fontFaceName; // raises(DOMException) on setting };
fontFaceName
of type DOMString
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly. |
format
of type CSSValueList
, readonly
uri
of type DOMString
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly. |
The CSS2FontFaceWidths
interface represents a simple value
for the
widths
CSS Level 2 descriptor.
// Introduced in DOM Level 2: interface CSS2FontFaceWidths { attribute DOMString urange; // raises(DOMException) on setting readonly attribute CSSValueList numbers; };
numbers
of type CSSValueList
, readonly
urange
of type DOMString
SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly. |
The following table specifies the type of CSSValue
used
to represent each property that can be specified in a
CSSStyleDeclaration
found in a CSSPageRule
for a CSS Level 2 style sheet.
Property Name | Representation |
margin | null |
margin-top, margin-right, margin-bottom, margin-left | length (no CSS_EMS and CSS_EXS), percentage, ident |
marks | list of idents |
size | CSS2PageSize |
The CSS2PageSize
interface represents the
size
CSS Level 2 descriptor.
// Introduced in DOM Level 2: interface CSS2PageSize : CSSValue { readonly attribute unsigned short widthType; readonly attribute unsigned short heightType; readonly attribute DOMString identifier; float getWidth(in float wType) raises(DOMException); float getHeightSize(in float hType) raises(DOMException); void setWidthSize(in unsigned short wType, in float value) raises(DOMException); void setHeightSize(in unsigned short hType, in float value) raises(DOMException); void setIdentifier(in DOMString ident) raises(DOMException); };
heightType
of type unsigned short
, readonlyCSS_EMS
, CSS_EXS
, CSS_PX
,
CSS_CM
, CSS_MM
, CSS_IN
,
CSS_PT
, CSS_PC
or CSS_IDENT
. If
one of width or height is CSS_IDENT
, it's guaranteed that
the other is the same.
identifier
of type DOMString
, readonlywidth
is CSS_IDENT
, this attribute
contains the string representation of the ident, otherwise it contains
an empty string.
widthType
of type unsigned short
, readonlyCSS_EMS
, CSS_EXS
, CSS_PX
,
CSS_CM
, CSS_MM
, CSS_IN
,
CSS_PT
, CSS_PC
or CSS_IDENT
.
getHeightSize
heightType
represents a length. If the float doesn't contain
a float value or can't be converted into the specified unit, a
DOMException
is raised. If only the width value has been
specified, the height value is the same.
|
| The height unit. |
|
The float value. |
INVALID_ACCESS_ERR: Raised if the property doesn't contain a float or the value can't be converted. |
getWidth
widthType
represents a length. If the float doesn't contain a
float value or can't be converted into the specified unit, a
DOMException
is raised.
|
| The width unit. |
|
The float value. |
INVALID_ACCESS_ERR: Raised if the property doesn't contain a float or the value can't be converted. |
setHeightSize
widthType
is not a length, it sets
the width position to the same value.
|
| The height unit. | ||
|
| The new value. |
INVALID_ACCESS_ERR: Raised if the specified unit is not a length or a percentage. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
setIdentifier
| The new identifier. |
SYNTAX_ERR: Raised if the identifier has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
setWidthSize
heightType
is not a length, it sets
the height position to the same value.
|
| The width unit. | ||
|
| The new value. |
INVALID_ACCESS_ERR: Raised if the specified unit is not a length or a percentage. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
The CSS2Properties
interface represents a convenience
mechanism for retrieving and setting properties within a
CSSStyleDeclaration
. The attributes of this interface
correspond to all the
properties specified in
CSS2. Getting an attribute of this interface is equivalent to
calling the getPropertyValue
method of the
CSSStyleDeclaration
interface. Setting an attribute of this
interface is equivalent to calling the setProperty
method of
the CSSStyleDeclaration
interface.
A compliant implementation is not required to implement the
CSS2Properties
interface. If an implementation does
implement this interface, the expectation is that language-specific
methods can be used to cast from an instance of the
CSSStyleDeclaration
interface to the
CSS2Properties
interface.
If an implementation does implement this interface, it is expected to
understand the specific syntax of the shorthand properties, and apply
their semantics; when the margin
property is set, for
example, the marginTop
, marginRight
,
marginBottom
and marginLeft
properties are
actually being set by the underlying implementation.
When dealing with CSS "shorthand" properties, the shorthand properties should be decomposed into their component longhand properties as appropriate, and when querying for their value, the form returned should be the shortest form exactly equivalent to the declarations made in the ruleset. However, if there is no shorthand declaration that could be added to the ruleset without changing in any way the rules already declared in the ruleset (i.e., by adding longhand rules that were previously not declared in the ruleset), then the empty string should be returned for the shorthand property.
For example, querying for the font
property should not
return "normal normal normal 14pt/normal Arial, sans-serif", when
"14pt Arial, sans-serif" suffices. (The normals are initial values,
and are implied by use of the longhand property.)
If the values for all the longhand properties that compose a
particular string are the initial values, then a string consisting of
all the initial values should be returned (e.g. a
border-width
value of "medium" should be returned as
such, not as "").
For some shorthand properties that take missing values from other
sides, such as the margin
, padding
, and
border-[width|style|color]
properties, the minimum
number of sides possible should be used; i.e., "0px 10px" will be
returned instead of "0px 10px 0px 10px".
If the value of a shorthand property can not be decomposed into its
component longhand properties, as is the case for the
font
property with a value of "menu", querying for the
values of the component longhand properties should return the empty
string.
// Introduced in DOM Level 2: interface CSS2Properties { attribute DOMString azimuth; // raises(DOMException) on setting attribute DOMString background; // raises(DOMException) on setting attribute DOMString backgroundAttachment; // raises(DOMException) on setting attribute DOMString backgroundColor; // raises(DOMException) on setting attribute DOMString backgroundImage; // raises(DOMException) on setting attribute DOMString backgroundPosition; // raises(DOMException) on setting attribute DOMString backgroundRepeat; // raises(DOMException) on setting attribute DOMString border; // raises(DOMException) on setting attribute DOMString borderCollapse; // raises(DOMException) on setting attribute DOMString borderColor; // raises(DOMException) on setting attribute DOMString borderSpacing; // raises(DOMException) on setting attribute DOMString borderStyle; // raises(DOMException) on setting attribute DOMString borderTop; // raises(DOMException) on setting attribute DOMString borderRight; // raises(DOMException) on setting attribute DOMString borderBottom; // raises(DOMException) on setting attribute DOMString borderLeft; // raises(DOMException) on setting attribute DOMString borderTopColor; // raises(DOMException) on setting attribute DOMString borderRightColor; // raises(DOMException) on setting attribute DOMString borderBottomColor; // raises(DOMException) on setting attribute DOMString borderLeftColor; // raises(DOMException) on setting attribute DOMString borderTopStyle; // raises(DOMException) on setting attribute DOMString borderRightStyle; // raises(DOMException) on setting attribute DOMString borderBottomStyle; // raises(DOMException) on setting attribute DOMString borderLeftStyle; // raises(DOMException) on setting attribute DOMString borderTopWidth; // raises(DOMException) on setting attribute DOMString borderRightWidth; // raises(DOMException) on setting attribute DOMString borderBottomWidth; // raises(DOMException) on setting attribute DOMString borderLeftWidth; // raises(DOMException) on setting attribute DOMString borderWidth; // raises(DOMException) on setting attribute DOMString bottom; // raises(DOMException) on setting attribute DOMString captionSide; // raises(DOMException) on setting attribute DOMString clear; // raises(DOMException) on setting attribute DOMString clip; // raises(DOMException) on setting attribute DOMString color; // raises(DOMException) on setting attribute DOMString content; // raises(DOMException) on setting attribute DOMString counterIncrement; // raises(DOMException) on setting attribute DOMString counterReset; // raises(DOMException) on setting attribute DOMString cue; // raises(DOMException) on setting attribute DOMString cueAfter; // raises(DOMException) on setting attribute DOMString cueBefore; // raises(DOMException) on setting attribute DOMString cursor; // raises(DOMException) on setting attribute DOMString direction; // raises(DOMException) on setting attribute DOMString display; // raises(DOMException) on setting attribute DOMString elevation; // raises(DOMException) on setting attribute DOMString emptyCells; // raises(DOMException) on setting attribute DOMString cssFloat; // raises(DOMException) on setting attribute DOMString font; // raises(DOMException) on setting attribute DOMString fontFamily; // raises(DOMException) on setting attribute DOMString fontSize; // raises(DOMException) on setting attribute DOMString fontSizeAdjust; // raises(DOMException) on setting attribute DOMString fontStretch; // raises(DOMException) on setting attribute DOMString fontStyle; // raises(DOMException) on setting attribute DOMString fontVariant; // raises(DOMException) on setting attribute DOMString fontWeight; // raises(DOMException) on setting attribute DOMString height; // raises(DOMException) on setting attribute DOMString left; // raises(DOMException) on setting attribute DOMString letterSpacing; // raises(DOMException) on setting attribute DOMString lineHeight; // raises(DOMException) on setting attribute DOMString listStyle; // raises(DOMException) on setting attribute DOMString listStyleImage; // raises(DOMException) on setting attribute DOMString listStylePosition; // raises(DOMException) on setting attribute DOMString listStyleType; // raises(DOMException) on setting attribute DOMString margin; // raises(DOMException) on setting attribute DOMString marginTop; // raises(DOMException) on setting attribute DOMString marginRight; // raises(DOMException) on setting attribute DOMString marginBottom; // raises(DOMException) on setting attribute DOMString marginLeft; // raises(DOMException) on setting attribute DOMString markerOffset; // raises(DOMException) on setting attribute DOMString marks; // raises(DOMException) on setting attribute DOMString maxHeight; // raises(DOMException) on setting attribute DOMString maxWidth; // raises(DOMException) on setting attribute DOMString minHeight; // raises(DOMException) on setting attribute DOMString minWidth; // raises(DOMException) on setting attribute DOMString orphans; // raises(DOMException) on setting attribute DOMString outline; // raises(DOMException) on setting attribute DOMString outlineColor; // raises(DOMException) on setting attribute DOMString outlineStyle; // raises(DOMException) on setting attribute DOMString outlineWidth; // raises(DOMException) on setting attribute DOMString overflow; // raises(DOMException) on setting attribute DOMString padding; // raises(DOMException) on setting attribute DOMString paddingTop; // raises(DOMException) on setting attribute DOMString paddingRight; // raises(DOMException) on setting attribute DOMString paddingBottom; // raises(DOMException) on setting attribute DOMString paddingLeft; // raises(DOMException) on setting attribute DOMString page; // raises(DOMException) on setting attribute DOMString pageBreakAfter; // raises(DOMException) on setting attribute DOMString pageBreakBefore; // raises(DOMException) on setting attribute DOMString pageBreakInside; // raises(DOMException) on setting attribute DOMString pause; // raises(DOMException) on setting attribute DOMString pauseAfter; // raises(DOMException) on setting attribute DOMString pauseBefore; // raises(DOMException) on setting attribute DOMString pitch; // raises(DOMException) on setting attribute DOMString pitchRange; // raises(DOMException) on setting attribute DOMString playDuring; // raises(DOMException) on setting attribute DOMString position; // raises(DOMException) on setting attribute DOMString quotes; // raises(DOMException) on setting attribute DOMString richness; // raises(DOMException) on setting attribute DOMString right; // raises(DOMException) on setting attribute DOMString size; // raises(DOMException) on setting attribute DOMString speak; // raises(DOMException) on setting attribute DOMString speakHeader; // raises(DOMException) on setting attribute DOMString speakNumeral; // raises(DOMException) on setting attribute DOMString speakPunctuation; // raises(DOMException) on setting attribute DOMString speechRate; // raises(DOMException) on setting attribute DOMString stress; // raises(DOMException) on setting attribute DOMString tableLayout; // raises(DOMException) on setting attribute DOMString textAlign; // raises(DOMException) on setting attribute DOMString textDecoration; // raises(DOMException) on setting attribute DOMString textIndent; // raises(DOMException) on setting attribute DOMString textShadow; // raises(DOMException) on setting attribute DOMString textTransform; // raises(DOMException) on setting attribute DOMString top; // raises(DOMException) on setting attribute DOMString unicodeBidi; // raises(DOMException) on setting attribute DOMString verticalAlign; // raises(DOMException) on setting attribute DOMString visibility; // raises(DOMException) on setting attribute DOMString voiceFamily; // raises(DOMException) on setting attribute DOMString volume; // raises(DOMException) on setting attribute DOMString whiteSpace; // raises(DOMException) on setting attribute DOMString widows; // raises(DOMException) on setting attribute DOMString width; // raises(DOMException) on setting attribute DOMString wordSpacing; // raises(DOMException) on setting attribute DOMString zIndex; // raises(DOMException) on setting };
azimuth
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
background
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
backgroundAttachment
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
backgroundColor
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
backgroundImage
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
backgroundPosition
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
backgroundRepeat
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
border
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderBottom
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderBottomColor
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderBottomStyle
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderBottomWidth
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderCollapse
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderColor
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderLeft
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderLeftColor
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderLeftStyle
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderLeftWidth
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderRight
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderRightColor
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderRightStyle
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderRightWidth
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderSpacing
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderStyle
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderTop
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderTopColor
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderTopStyle
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderTopWidth
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
borderWidth
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
bottom
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
captionSide
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
clear
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
clip
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
color
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
content
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
counterIncrement
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
counterReset
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
cssFloat
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
cue
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
cueAfter
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
cueBefore
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
cursor
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
direction
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
display
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
elevation
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
emptyCells
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
font
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
fontFamily
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
fontSize
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
fontSizeAdjust
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
fontStretch
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
fontStyle
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
fontVariant
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
fontWeight
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
height
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
left
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
letterSpacing
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
lineHeight
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
listStyle
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
listStyleImage
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
listStylePosition
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
listStyleType
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
margin
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
marginBottom
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
marginLeft
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
marginRight
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
marginTop
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
markerOffset
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
marks
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
maxHeight
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
maxWidth
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
minHeight
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
minWidth
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
orphans
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
outline
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
outlineColor
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
outlineStyle
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
outlineWidth
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
overflow
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
padding
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
paddingBottom
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
paddingLeft
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
paddingRight
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
paddingTop
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
page
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
pageBreakAfter
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
pageBreakBefore
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
pageBreakInside
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
pause
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
pauseAfter
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
pauseBefore
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
pitch
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
pitchRange
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
playDuring
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
position
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
quotes
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
richness
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
right
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
size
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
speak
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
speakHeader
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
speakNumeral
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
speakPunctuation
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
speechRate
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
stress
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
tableLayout
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
textAlign
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
textDecoration
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
textIndent
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
textShadow
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
textTransform
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
top
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
unicodeBidi
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
verticalAlign
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
visibility
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
voiceFamily
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
volume
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
whiteSpace
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
widows
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
width
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
wordSpacing
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
zIndex
of type DOMString
SYNTAX_ERR: Raised if the new value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
The DOM Level 2 Event Model is designed with two main goals. The first goal is the design of a generic event system which allows registration of event handlers, describes event flow through a tree structure, and provides basic contextual information for each event. Additionally, the specification will provide standard sets of events for user interface control and document mutation notifications, including defined contextual information for each of these event sets.
The second goal of the event model is to provide a common subset of the current event systems used in DOM Level 0 browsers. This is intended to foster interoperability of existing scripts and content. It is not expected that this goal will be met with full backwards compatibility. However, the specification attempts to achieve this when possible.
The following sections of the Event Model specification define both the specification
for the DOM Event Model and a number of compliant event sets designed for use within the
model. The Event Model consists of the two sections on event propagation and event listener
registration and the Event interface. A DOM consumer can use the hasFeature
of the DOMImplementation
interface to determine whether the Event
Model has been implemented by a DOM implementation. The feature string for the
Event Model is "Events". The existence within an implementation of each of the
individual event sets can also be queried using the hasFeature
method.
Each event set describes its own feature string in the event set listing.
Event flow is the process through which the an event originates from the DOM implementation
and is passed into the Document Object Model. The methods of event capture and event
bubbling, along with various event listener registration techniques, allow the event
to then be handled in a number of ways. It can be handled locally at the
EventTarget
level or centrally from an EventTarget
higher in the document tree.
Each event has an EventTarget
toward which the event is directed by the DOM implementation. This
EventTarget
is specified in the Event
's target
attribute. When
the event reaches the target, any event
listeners registered on the EventTarget
are triggered. Although all EventListeners
on the EventTarget
are guaranteed to be triggered by any event which is received by that
EventTarget
, no specification is made as to the order
in which they will receive the event with regards to the other EventListeners
on the
EventTarget
. If neither event
capture or event bubbling are in use for that particular event,
the event flow process will complete after all listeners have been triggered. If event capture
or event bubbling is in use, the event flow will be modified as described in the sections below.
Any exceptions thrown inside an EventListener
will not stop propagation of the
event. It will continue processing any additional EventListener
in the described manner.
It is expected that actions taken by EventListener
s may cause additional events to
fire. Additional events should be handled in a synchronous manner and may cause reentrancy into
the event model.
Event capture is the process by which an EventListener registered on an ancestor
of the event's target can intercept events of a given type before they
are received by the event's target. Capture operates from
the top of the tree, generally the Document
, downward, making it the symmetrical opposite of bubbling
which is described below. The chain of EventTarget
s from the top of the tree
to the event's target is determined before the initial dispatch of the event. If modifications
occur to the tree during event processing, event flow will proceed based on the initial state of the tree.
An EventListener
being registered on an EventTarget
may choose to have that EventListener
capture events by
specifying the useCapture
parameter of the addEventListener
method to be true
. Thereafter, when an event of the given type is
dispatched toward a descendant of the capturing object, the event
will trigger any capturing event listeners of the appropriate type
which exist in the direct line between the top of the document and the
event's target. This downward propagation continues until the event's target is
reached. A capturing EventListener
will not be triggered by events
dispatched directly to the EventTarget
upon which it is registered.
If the capturing EventListener
wishes to prevent further
processing of the event from occurring it may call the stopProgagation
method of
the Event
interface. This will prevent further dispatch of the event, although additional EventListeners
registered at
the same hierarchy level will still receive the event. Once an event's
stopPropagation
method has been called, further calls to that method have
no additional effect. If no additional capturers exist and stopPropagation
has not been called,
the event triggers the appropriate EventListeners
on the target
itself.
Although event capture is similar to the delegation based event
model in which all interested parties register their listeners directly on the target
about which they wish to receive notifications, it is different in two important respects.
First, event capture only allows interception of events which are targeted at descendants
of the capturing EventTarget
. It does not allow interception of events
targeted to the capturer's ancestors, its siblings, or its
sibling's descendants. Secondly, event capture is not specified for
a single EventTarget
, it is specified for a specific type of event.
Once specified, event capture intercepts all events
of the specified type targeted toward any of the capturer's descendants.
Events which are designated as bubbling will initially proceed with the
same event flow as non-bubbling events. The event is dispatched to its target
EventTarget
and any event listeners found there are triggered. Bubbling
events will then trigger any additional event listeners found by following the
EventTarget
's parent chain upward, checking for any event listeners
registered on each successive EventTarget
. This upward propagation will continue
up to and including the Document
. EventListener
s registered as
capturers will not be triggered during this phase. The chain of EventTarget
s from the event
target to the top of the tree is determined before the initial dispatch of the event. If modifications
occur to the tree during event processing, event flow will proceed based on the initial state of the tree.
Any event handler may choose to prevent further event propagation
by calling the stopPropagation
method of the Event
interface. If
any EventListener
calls this method, all additional EventListeners
on the current EventTarget
will be triggered but bubbling
will cease at that level. Only one call to stopPropagation
is required to
prevent further bubbling.
Some events are specified as cancelable. For these events, the DOM implementation generally has a default action associated with the event. An example of this is a hyperlink in a web browser. When the user clicks on the hyperlink the default action is generally to active that hyperlink. Before processing these events, the implementation must check for event listeners registered to receive the event and dispatch the event to those listeners. These listeners then have the option of canceling the implementation's default action or allowing the default action to proceed. In the case of the hyperlink in the browser, canceling the action would have the result of not activating the hyperlink.
Cancelation is accomplished by calling the Event
's
preventDefault
method. If one or more EventListeners
call
preventDefault
during any phase of event flow the default action will
be canceled.
Different implementations will specify their own default actions, if any, associated with each event. The DOM does not attempt to specify these actions.
The EventTarget
interface is implemented by all Nodes
in
an implementation which supports the DOM Event Model. The interface allows registration
and removal of EventListeners
on an EventTarget
and dispatch
of events to that EventTarget
.
// Introduced in DOM Level 2: interface EventTarget { void addEventListener(in DOMString type, in EventListener listener, in boolean useCapture); void removeEventListener(in DOMString type, in EventListener listener, in boolean useCapture); boolean dispatchEvent(in Event evt) raises(EventException); };
addEventListener
EventListener
is added to an EventTarget
while it is
processing an event, it will not be triggered by the current actions but may be
triggered during a later stage of event flow, such as the bubbling phase.
EventListener
s are registered on the same
EventTarget
with the same parameters the duplicate instances are discarded.
They do not cause the EventListener
to be called twice and since they are
discarded they do not need to be removed with the removeEventListener
method.
| The event type for which the user is registering | |||
| The | |||
|
| If true, |
dispatchEvent
EventTarget
on which dispatchEvent
is called.
| Specifies the event type, behavior, and contextual information to be used in processing the event. |
|
The return value of |
removeEventListener
EventListener
is removed from an EventTarget
while it is
processing an event, it will still be triggered by the current actions but will not
be triggered again during any later stages of event flow, such as bubbling.removeEventListener
with arguments which do not identify any
currently registered EventListener
on the EventTarget
has no effect.
| Specifies the event type of the | |||
| The | |||
|
| Specifies whether the |
The EventListener
interface is the primary method for
handling events. Users implement the EventListener
interface
and register their listener on an EventTarget
using the
AddEventListener
method. The users should also remove their
EventListener
from its EventTarget
after they
have completed using the listener.
When a Node
is copied using the cloneNode
method
the EventListener
s attached to the source Node
are
not attached to the copied Node
. If the user wishes the same
EventListener
s to be added to the newly created copy the user must add them manually.
// Introduced in DOM Level 2: interface EventListener { void handleEvent(in Event evt); };
handleEvent
EventListener
interface was registered.
In HTML 4.0, event listeners were specified as attributes of an element. As such,
registration of a second event listener of the same type would replace the
first listener. The DOM Event Model allows registration of multiple event listeners on
a single Node
. To achieve this, event listeners are no longer stored as attribute
values.
In order to achieve compatibility with HTML 4.0, implementors may view the setting of
attributes which represent event handlers as the creation and registration of an
EventListener
on the Node
. The value of useCapture
defaults to false
. This EventListener
behaves in
the same manner as any other EventListeners
which may be registered on the
EventTarget
. If the attribute representing the event listener is changed, this may be
viewed as the removal of the previously registered EventListener
and the
registration of a new one. No technique is provided to allow HTML 4.0 event listeners
access to the context information defined for each event.
The Event
interface is used to provide contextual information about an event
to the handler processing the event. An object which implements the Event
interface
is generally passed as the first parameter to an event handler. More specific
context information is passed to event handlers by deriving additional interfaces from
Event
which contain information directly relating to the type of event
they accompany. These derived interfaces are also implemented by the object passed to the
event listener.
// Introduced in DOM Level 2: interface Event { // PhaseType const unsigned short CAPTURING_PHASE = 1; const unsigned short AT_TARGET = 2; const unsigned short BUBBLING_PHASE = 3; readonly attribute DOMString type; readonly attribute EventTarget target; readonly attribute Node currentNode; readonly attribute unsigned short eventPhase; readonly attribute boolean bubbles; readonly attribute boolean cancelable; readonly attribute DOMTimeStamp timeStamp; void stopPropagation(); void preventDefault(); void initEvent(in DOMString eventTypeArg, in boolean canBubbleArg, in boolean cancelableArg); };
An integer indicating which phase of event flow is being processed.
AT_TARGET | The event is currently being evaluated at the target node. |
BUBBLING_PHASE | The current event phase is the bubbling phase. |
CAPTURING_PHASE | The current event phase is the capturing phase. |
bubbles
of type boolean
, readonly
cancelable
of type boolean
, readonly
currentNode
of type Node
, readonlyNode
whose
EventListeners
are currently being processed. This is particularly
useful during capturing and bubbling.
eventPhase
of type unsigned short
, readonly
target
of type EventTarget
, readonlyEventTarget
to which the event
was originally dispatched.
timeStamp
of type DOMTimeStamp
, readonlytimeStamp
may be not available for all events. When not
available, a value of 0 will be returned. Examples of epoch time are
the time of the system start or 0:0:0 UTC 1st January 1970.
type
of type DOMString
, readonly
initEvent
initEvent
method is used to initialize the value of an Event
created through
the DocumentEvent
interface. This method may only be called before the Event
has
been dispatched via the dispatchEvent
method, though it may be called multiple times during that
phase if necessary. If called multiple times the final invocation takes precedence. If called from a
subclass of Event
interface only the values specified in the initEvent
method are
modified, all other attributes are left unchanged.
| Specifies the event type. This type may be any event type currently defined in this specification or a new event type.. The string must be an XML name. Any new event type must not begin with any upper, lower, or mixed case version of the string "DOM". This prefix is reserved for future DOM event sets. | |||
|
| Specifies whether or not the event can bubble. | ||
|
| Specifies whether or not the event's default action can be prevented. |
preventDefault
preventDefault
method is used
to signify that the event is to be canceled, meaning any default action normally
taken by the implementation as a result of the event will not occur. If, during any stage of event flow,
the preventDefault
method is called the event is canceled.
Any default action associated with the event will not occur. Calling this method
for a non-cancelable event has no effect. Once preventDefault
has been
called it will remain in effect throughout the remainder of the event's propagation. This
method may be used during any stage of event flow.
stopPropagation
stopPropagation
method is used prevent further propagation of an event during
event flow. If this method is called by any EventListener
the event will cease
propagating through the tree. The event will complete dispatch to all listeners on the current
EventTarget
before event flow stops. This method may be used during any stage of
event flow.
Event operations may throw an EventException
as specified in
their method descriptions.
// Introduced in DOM Level 2: exception EventException { unsigned short code; }; // EventExceptionCode const unsigned short UNSPECIFIED_EVENT_TYPE_ERR = 0;
An integer indicating the type of error generated.
UNSPECIFIED_EVENT_TYPE_ERR |
If the Event 's type was not specified by initializing the
event before the method was called. Specification of the Event's type
as null or an empty string will also trigger this
exception.
|
The DocumentEvent
interface provides a mechanism by
which the user can create an Event of a type supported by the implementation.
It is expected that the DocumentEvent
interface will be implemented
on the same object which implements the Document
interface in an
implementation which supports the Event model.
// Introduced in DOM Level 2: interface DocumentEvent { Event createEvent(in DOMString eventType) raises(DOMException); };
createEvent
| The The |
NOT_SUPPORTED_ERR: Raised if the implementation does not support
the type of |
The DOM Level 2 Event Model allows a DOM implementation to support multiple sets of events. The model has been designed to allow addition of new event sets as is required. The DOM will not attempt to define all possible events. For purposes of interoperability, the DOM will define a set of user interface events including lower level device dependent events, a set of UI logical events, and a set of document mutation events.
The User Interface event set is composed of events listed in HTML 4.0 and additional events which are supported in DOM Level 0 browsers.
A DOM consumer can use the hasFeature
of the
DOMImplementation
interface to determine whether the User Interface
event set has been implemented by a DOM implementation. The feature string
for this event set is "UIEvents". This string is also used with the createEvent
method.
The UIEvent
interface provides specific contextual
information associated with User Interface events.
// Introduced in DOM Level 2: interface UIEvent : Event { readonly attribute views::AbstractView view; readonly attribute long detail; void initUIEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in views::AbstractView viewArg, in long detailArg); };
detail
of type long
, readonlyEvent
,
depending on the type of event.
view
of type views::AbstractView
, readonlyview
attribute identifies the
AbstractView
from which the event was generated.
initUIEvent
initUIEvent
method is used to initialize the value of a UIEvent
created through
the DocumentEvent
interface. This method may only be called before the UIEvent
has
been dispatched via the dispatchEvent
method, though it may be called multiple times during that
phase if necessary. If called multiple times, the final invocation takes precedence.
| Specifies the event type. | |||
|
| Specifies whether or not the event can bubble. | ||
|
| Specifies whether or not the event's default action can be prevented. | ||
|
| Specifies the | ||
|
| Specifies the |
The different types of such events that can occur are:
The Mouse event set is composed of events listed in HTML 4.0 and additional events which are supported in DOM Level 0 browsers. This event set is specifically designed for use with mouse input devices.
A DOM consumer can use the hasFeature
of the
DOMImplementation
interface to determine whether the User Interface
event set has been implemented by a DOM implementation. The feature string
for this event set is "MouseEvents". This string is also used with the createEvent
method.
The MouseEvent
interface provides specific contextual
information associated with Mouse events.
The detail
attribute inherited from UIEvent
indicates the number of times a mouse button has been pressed and
released over the same screen location during a user action. The
attribute value is 1 when the user begins this action and increments by 1
for each full sequence of pressing and releasing. If the user moves the
mouse between the mousedown and mouseup the value will be set to 0,
indicating that no click is occurring.
In the case of nested elements mouse events are always targeted at the most deeply nested element. Ancestors of the targeted element may use bubbling to obtain notification of mouse events which occur within its descendent elements.
// Introduced in DOM Level 2: interface MouseEvent : UIEvent { readonly attribute long screenX; readonly attribute long screenY; readonly attribute long clientX; readonly attribute long clientY; readonly attribute boolean ctrlKey; readonly attribute boolean shiftKey; readonly attribute boolean altKey; readonly attribute boolean metaKey; readonly attribute unsigned short button; readonly attribute Node relatedNode; void initMouseEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in views::AbstractView viewArg, in long detailArg, in long screenXArg, in long screenYArg, in long clientXArg, in long clientYArg, in boolean ctrlKeyArg, in boolean altKeyArg, in boolean shiftKeyArg, in boolean metaKeyArg, in unsigned short buttonArg, in Node relatedNodeArg); };
altKey
of type boolean
, readonly
button
of type unsigned short
, readonlybutton
is used to indicate which mouse button
changed state. The values for button
range from zero to indicate
the left button of the mouse, one to indicate the middle button if present, and
two to indicate the right button. For mice configured for left handed use in which
the button actions are reversed the values are instead read from right to left.
clientX
of type long
, readonly
clientY
of type long
, readonly
ctrlKey
of type boolean
, readonly
metaKey
of type boolean
, readonly
relatedNode
of type Node
, readonlyNode
which the pointing device exited and with the mouseout event to indicate the
Node
which the pointing device entered.
screenX
of type long
, readonly
screenY
of type long
, readonly
shiftKey
of type boolean
, readonly
initMouseEvent
initMouseEvent
method is used to initialize the value of a MouseEvent
created through
the DocumentEvent
interface. This method may only be called before the MouseEvent
has
been dispatched via the dispatchEvent
method, though it may be called multiple times during that
phase if necessary. If called multiple times, the final invocation takes precedence.
| Specifies the event type. | |||
|
| Specifies whether or not the event can bubble. | ||
|
| Specifies whether or not the event's default action can be prevented. | ||
|
| Specifies the | ||
|
| Specifies the | ||
|
| Specifies the | ||
|
| Specifies the | ||
|
| Specifies the | ||
|
| Specifies the | ||
|
| Specifies whether or not control key was depressed during
the | ||
|
| Specifies whether or not alt key was depressed during the
| ||
|
| Specifies whether or not shift key was depressed during the
| ||
|
| Specifies whether or not meta key was depressed during the
| ||
|
| Specifies the | ||
| Specifies the |
The different types of Mouse events that can occur are:
mousedown mouseup click
detail
attribute incrementing with each repetition.
This event is valid for most elements.Node
the pointing device is exiting.Node
the pointing device is entering.The DOM Level 2 Event specification does not provide a key event set. An event set designed for use with keyboard input devices will be included in a later version of the DOM specification.
The mutation event set is designed to allow notification of any changes to the structure of a document, including attr and text modifications. It may be noted that none of the mutation events listed are designated as cancelable. This stems from the fact that it is very difficult to make use of existing DOM interfaces which cause document modifications if any change to the document might or might not take place due to cancelation of the related event. Although this is still a desired capability, it was decided that it would be better left until the addition of transactions into the DOM.
Many single modifications of the tree can cause multiple mutation events to be fired. Rather than attempt to specify the ordering of mutation events due to every possible modification of the tree, the ordering of these events is left to the implementation.
A DOM consumer can use the hasFeature
of the
DOMImplementation
interface to determine whether the mutation
event set has been implemented by a DOM implementation. The feature string
for this event set is "MutationEvents". This string is also used with the createEvent
method.
The MutationEvent
interface provides specific contextual
information associated with Mutation events.
// Introduced in DOM Level 2: interface MutationEvent : Event { readonly attribute Node relatedNode; readonly attribute DOMString prevValue; readonly attribute DOMString newValue; readonly attribute DOMString attrName; void initMutationEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in Node relatedNodeArg, in DOMString prevValueArg, in DOMString newValueArg, in DOMString attrNameArg); };
attrName
of type DOMString
, readonlyattrName
indicates the name of the changed Attr
node in a
DOMAttrModified event.
newValue
of type DOMString
, readonlynewValue
indicates the new value of the Attr
node in DOMAttrModified
events, and of the CharacterData
node in DOMCharDataModified events.
prevValue
of type DOMString
, readonlyprevValue
indicates the previous value of the Attr
node in
DOMAttrModified events, and of the CharacterData
node in DOMCharDataModified events.
relatedNode
of type Node
, readonlyrelatedNode
is used to identify a secondary node related to a mutation event.
For example, if a mutation event is dispatched to a node indicating that its parent
has changed, the relatedNode
is the changed parent. If an event is instead
dispatch to a subtree indicating a node was changed within it, the relatedNode
is the changed node.
initMutationEvent
initMutationEvent
method is used to initialize the value of a MutationEvent
created through
the DocumentEvent
interface. This method may only be called before the MutationEvent
has
been dispatched via the dispatchEvent
method, though it may be called multiple times during that
phase if necessary. If called multiple times, the final invocation takes precedence.
| Specifies the event type. | |||
|
| Specifies whether or not the event can bubble. | ||
|
| Specifies whether or not the event's default action can be prevented. | ||
| Specifies the | |||
| Specifies the | |||
| Specifies the | |||
| Specifies the |
The different types of Mutation events that can occur are:
Attr
has been modified on a node. The target of this
event is the Node
whose Attr
changed. The values of prevValue
and newValue may be the empty string in cases where an attribute has been added or removed.The HTML event set is composed of events listed in HTML 4.0 and additional events which are supported in DOM Level 0 browsers.
A DOM consumer can use the hasFeature
of the
DOMImplementation
interface to determine whether the HTML
event set has been implemented by a DOM implementation. The feature string
for this event set is "HTMLEvents". This string is also used with the createEvent
method.
The HTML events use the base DOM Event interface to pass contextual information.
The different types of such events that can occur are:
This chapter describes the optional DOM Level 2 Traversal feature. Its
TreeWalker, NodeIterator, and Filter interfaces provide easy-to-use, robust,
selective traversal for document nodes. A DOM application can use the
hasFeature
method of the DOMImplementation
interface
to determine whether they are supported or not. The feature string for all the
interfaces listed in this section is "Traversal". Iterators and TreeWalkers are
two different ways of representing the nodes of a document subtree and a
position within the nodes they present. A NodeIterator presents a flattened
view of the subtree as an ordered sequence of document nodes, presented in
document order. Because this view is presented without respect to hierarchy,
iterators have methods to move forward and backward, but not to move up and
down. A TreeWalker maintains the hierarchical relationships of the subtree,
allowing navigation of this hierarchy. In general, TreeWalkers are better for
tasks in which the structure of the document around selected nodes will be
manipulated, while iterators are better for tasks that focus on the content of
each selected node.
Iterators and TreeWalkers each present a view of a document subtree that may not contain all nodes found in the subtree. In this specification, we refer to this as the logical view to distinguish it from the physical view, which corresponds to the document subtree per se. When an iterator or TreeWalker is created, it may be associated with a Filter, which examines a node and determines whether it should appear in the logical view. In addition, flags may be used to specify which node types should occur in the logical view.
Iterators and TreeWalkers are dynamic - the logical view changes to reflect changes made to the underlying document. However, they differ in how they respond to those changes. NodeIterators, which present the nodes sequentially, attempt to maintain their location relative to a position in that sequence when the sequence's contents change. TreeWalkers, which present the nodes as a filtered tree, maintain their location relative to their current node, and remain attached to that node if it is moved to a new context. We will discuss these behaviors in greater detail below.
An iterator allows the members of a list of nodes to be returned
sequentially. In the current DOM interfaces, this list will always consist of
the nodes of a subtree, presented in document order. When an iterator is first
created, calling nextNode() returns the first node in the logical view of the
subtree; in most cases, this is the root of the subtree. When no more nodes are
present, nextNode() returns null
.
Iterators are created using the createNodeIterator method found in the
DocumentTraversal
interface. When a NodeIterator is created, flags
can be used to determine which node types will be "visible" and which nodes
will be "invisible" while traversing the tree; these flags can be combined
using the OR operator. Nodes that are "invisible" are skipped over by the
iterator as though they did not exist. The following code creates an iterator,
then calls a function to print the name of each element:
NodeIterator iter=((DocumentTraversal)document).createNodeIterator(root, NodeFilter.SHOW_ELEMENT, null); while (Node n = iter.nextNode()) printMe(n);
Iterators present nodes as an ordered list, and move forward and backward within this list. The iterator's position is always between two nodes, before the first node, or after the last node. When an iterator is first created, the position is set before the first item. The following diagram shows the list view that an iterator might provide for a particular subtree, with the position indicated by an asterisk '*' :
* A B C D E F G H I
Each call to nextNode() returns the next node and advances the position. For instance, if we start with the above position, the first call to nextNode() returns "A" and advances the iterator:
[A] * B C D E F G H I
The position of an iterator can best be described with respect to the last node returned, which we will call the reference node. When an iterator is created, the first node is the reference node, and the iterator is positioned before the reference node. In these diagrams, we use square brackets to indicate the reference node.
A call to previousNode() returns the previous node and moves the position backward. For instance, if we start with the iterator between "A" and "B", it would return "A" and move to the position shown below:
* [A] B C D E F G H I
If nextNode() is called at the end of a list, or previousNode() is
called at the beginning of a list, it returns null
and does not
change the position of the iterator. When an iterator is first created, the
reference node is the first node:
* [A] B C D E F G H I
An iterator may be active while the data structure it navigates is being edited, so an iterator must behave gracefully in the face of change. Additions and removals in the underlying data structure do not invalidate an iterator; in fact, an iterator is never invalidated unless its detach() method is invoked. To make this possible, the iterator uses the reference node to maintain its position. The state of an iterator also depends on whether the iterator is positioned before or after the reference node. If the reference node is removed, another node becomes the reference node.
If changes to the iterated list do not remove the reference node, they do not affect the state of the iterator. For instance, the iterator's state is not affected by inserting new nodes in the vicinity of the iterator or removing nodes other than the reference node. Suppose we start from the following position:
A B C [D] * E F G H I
Now let's remove "E". The resulting state is:
A B C [D] * F G H I
If a new node is inserted, the iterator stays close to the reference node, so if a node is inserted between "D" and "F", it will occur between the iterator and "F":
A B C [D] * X F G H I
Moving a node is equivalent to a removal followed by an insertion. If we move "I" to the position before "X" the result is:
A B C [D] * I X F G H
If the reference node is removed, a different node is selected as the reference node. If the reference node is before the iterator, which is usually the case after nextNode() has been called, the nearest node before the iterator is chosen as the new reference node. Suppose we remove the "D" node, starting from the following state:
A B C [D] * F G H I
The "C" node becomes the new reference node, since it is the nearest node to the iterator that is before the iterator:
A B [C] * F G H I
If the reference node is after the iterator, which is usually the case after previousNode() has been called, the nearest node after the iterator is chosen as the new reference node. Suppose we remove "E", starting from the following state:
A B C D * [E] F G H I
The "F" node becomes the new reference node, since it is the nearest node to the iterator that is after the iterator:
A B C D * [F] G H I
Moving a node is equivalent to a removal followed by an insertion. Suppose we wish to move the "D" node to the end of the list, starting from the following state:
A B C [D] * F G H I C
The resulting state is as follows:
A B [C] * F G H I D
One special case arises when the reference node is the last node in the list and the reference node is removed. Suppose we remove node "C", starting from the following state:
A B * [C]
According to the rules we have given, the new reference node should be the nearest node after the iterator, but there are no further nodes after "C". The same situation can arise when previousNode() has just returned the first node in the list, which is then removed. Hence: If there is no node in the original direction of the reference node, the nearest node in the opposite direction is selected as the reference node:
A [B] *
If the iterator is positioned within a block of nodes that is removed, the above rules clearly indicate what is to be done. For instance, suppose "C" is the parent node of "D", "E", and "F", and we remove "C", starting with the following state:
A B C [D] * E F G H I D
The resulting state is as follows:
A [B] * G H I D
The underlying data structure that is being iterated may contain nodes that are not part of the logical view, and therefore will not be returned by the iterator. If invisible nodes are present, nextNode() returns the next visible node, skipping over nodes that are to be excluded because of the value of the whatToShow flag. If a filter is present, it is applied before returning a node; if the filter does not accept the node, the process is repeated until a node is accepted by the filter. That node is returned. If no visible nodes are encountered, a null is returned and the iterator is positioned at the end of the list. In this case, the reference node is the last node in the list, whether or not it is visible. The same approach is taken, in the opposite direction, for previousNode().
In the following examples, we will use lowercase letters to represent nodes that are in the data structure, but which are not in the logical view. For instance, consider the following list:
A [B] * c d E F G
A call to nextNode() returns E and advances to the following position:
A B c d [E] * F G
Nodes that are not visible may nevertheless be used as reference nodes if a reference node is removed. Suppose node "E" is removed, started from the state given above. The resulting state is:
A B c [d] * F G
Suppose a new node "X", which is visible, is inserted before "d". The resulting state is:
A B c X [d] * F G
Note that a call to previousNode() now returns node X. It is important not to skip over invisible nodes when the reference node is removed, because there are cases, like the one just given above, where the wrong results will be returned. When "E" was removed, if the new reference node had been "B" rather than "d", calling previousNode() would not return "X".
Filters allow the user to create objects that "filter out" nodes. Each filter contains a user-written function that looks at a node and determines whether or not it should be filtered out. To use a filter, you create a NodeIterator or a TreeWalker that uses the filter. The Iterator or TreeWalker applies the filter to each node, and if the filter does not accept the node, the iterator or TreeWalker skips over the node as though it were not present in the document. Filters need not know how to navigate the structure that contains the nodes on which they operate.
Filters will be consulted when a traversal operation is performed, or when a NodeIterator's reference node is removed from the subtree being iterated over and it must select a new one. However, the exact timing of these filter calls may vary from one DOM implementation to another. For that reason, filters should not attempt to maintain state based on the history of past invocations; the resulting behavior may not be portable.
Similarly, TreeWalkers and NodeIterators should behave as if they have no memory of past filter results, and no anticipation of future results. If the conditions a filter is examining have changed (e.g., an attribute which it tests has been added or removed) since the last time the traversal logic examined this node, this change in visibility will be discovered only when the next traversal operation is performed. For example: if the filtering for the current node changes from FILTER_SHOW to FILTER_SKIP, a TreeWalker will be able to navigate off that node in any direction, but not back to it unless the filtering conditions change again. Filters which change during a traversal can be written, but their behavior may be confusing and they should be avoided when possible.
A Filter contains one method named acceptNode(), which allows an iterator or TreeWalker to pass a Node to a filter and ask whether it should be present in the logical view. The acceptNode() function returns one of three values to state how the Node should be treated. If acceptNode() returns FILTER_ACCEPT, the Node will be present in the logical view; if it returns FILTER_SKIP, the Node will not be present in the logical view, but the children of the Node may; if it returns FILTER_REJECT, neither the Node nor its descendants will be present in the logical view. Since iterators present nodes as an ordered list, without hierarchy, FILTER_REJECT and FILTER_SKIP are synonyms for iterators, skipping only the single current node.
Consider a filter that accepts the named anchors in an HTML document. In HTML, an HREF can refer to any A element that has a NAME attribute. Here is a filter in Java that looks at a node and determines whether it is a named anchor:
class NamedAnchorFilter implements NodeFilter { short acceptNode(Node n) { if (n.getNodeType()==Node.ELEMENT_NODE) { Element e = (Element)n; if (! e.getNodeName().equals("A")) return FILTER_SKIP; if (e.getAttributeNode("NAME") != null) { return FILTER_ACCEPT; } } return FILTER_SKIP; } }
If the above Filter were to be used only with NodeIterators, it could have used FILTER_REJECT wherever FILTER_SKIP is used, and the behavior would not change. For TreeWalker, though, FILTER_REJECT would reject the children of any element that is not a named anchor, and since named anchors are always contained within other elements, this would have meant that no named anchors would be found. FILTER_SKIP rejects the given node, but continues to examine the children; therefore, the above filter will work with either a NodeIterator or a TreeWalker.
To use this filter, the user would create an instance of the filter and create an iterator using it:
NamedAnchorFilter myFilter = new NamedAnchorFilter(); NodeIterator iter=((DocumentTraversal)document).createNodeIterator(node, NodeFilter.SHOW_ELEMENT, myFilter);
Note that the use of the SHOW_ELEMENT flag is not strictly necessary in this example, since our sample Filter tests the nodeType. However, some implementations of the Traversal interfaces may be able to improve whatToShow performance by taking advantage of knowledge of the document's structure, which makes the use of SHOW_ELEMENT worthwhile. Conversely, while we could remove the nodeType test from our Filter, that would make it dependent upon whatToShow to distinguish between Elements, Attr's, and ProcessingInstructions.
When writing a Filter, users should avoid writing code that can throw an exception. However, because an implementation can not prevent users from doing so, it is important that the behavior of filters that throw an exception be well-defined. A TreeWalker or NodeIterator does not catch or alter an exception thrown by a filter, but lets it propagate up to the user's code. The following functions may invoke a Filter, and may therefore propagate an exception if one is thrown by a Filter:
Well-designed Filters do not modify the underlying document structure, but a Filter implementation can not prevent a user from writing code that does modify the document structure. Filters do not provide any special processing to handle this case. For instance, if a Filter removes a node from a document, it can still accept the node, which means that the node may be returned by the NodeIterator or TreeWalker even though it is no longer in the document. In general, this may lead to inconsistent, confusing results, so we encourage users to write Filters that make no changes to document structures.
Iterator and TreeWalker apply whatToShow flags before applying Filters. If a node is skipped by the active whatToShow flags, a Filter will not be called to evaluate that node. Please note that this behavior is similar to that of FILTER_SKIP; children of that node will be considered, and Filters may be called to evaluate them. Also note that it will in fact be a "skip" even if the Filter would have preferred to reject the entire subtree; if this would cause a problem in your application, consider setting whatToShow to SHOW_ALL and performing the nodeType test inside your filter.
The TreeWalker
interface provides many of the same benefits as
the NodeIterator interface. The main difference between these two interfaces is
that the TreeWalker
presents a tree-oriented view of the nodes in
a subtree, and an iterator presents a list-oriented view. In other words, an
iterator allows you to move forward or back, but a TreeWalker
allows you to move to the parent of a node, to one of its children, or to a
sibling.
Using a TreeWalker
is quite similar to navigation using the
Node directly, and the navigation methods for the two interfaces are analogous.
For instance, here is a function that walks over a tree of nodes in document
order, taking separate actions when first entering a node and after processing
any children:
processMe(Node n) { nodeStartActions(n); for (Node child=n.firstChild(); child != null; child=child.nextSibling()) processMe(child); } nodeEndActions(n); }
Doing the same thing using a TreeWalker
is quite similar. There
is one difference: since navigation on the TreeWalker
changes the
current position, the position at the end of the function has changed. A
read/write attribute named currentNode
allows the current node for
a TreeWalker
to be set. We will use this to ensure that the
position of the TreeWalker
is restored when this function is
completed:
processMe(TreeWalker tw) { Node n = tw.getCurrentNode(); nodeStartActions(tw); for (Node child=tw.firstChild(); child!=null; child=tw.nextSibling()) { processMe(tw); } tw.setCurrentNode(n); nodeEndActions(tw); }
The advantage of using a TreeWalker
instead of direct Node
navigation is that the TreeWalker
allows the user to choose an
appropriate view of the tree. Flags may be used to show or hide comments or
processing instructions, entities may be expanded or left as entity references.
In addition, Filters may be used to present a custom view of the tree. Suppose
a program needs a view of a document that shows which tables occur in each
chapter, listed by chapter. In this view, only the chapter elements and the
tables that they contain are seen. The first step is to write an appropriate
filter:
class TablesInChapters implements NodeFilter { short acceptNode(Node n) { if (n.getNodeType()==Node.ELEMENT_NODE) { if (n.getNodeName().equals("CHAPTER")) return FILTER_ACCEPT; if (n.getNodeName().equals("TABLE")) return FILTER_ACCEPT; if (n.getNodeName().equals("SECT1") || n.getNodeName().equals("SECT2") || n.getNodeName().equals("SECT3") || n.getNodeName().equals("SECT4") || n.getNodeName().equals("SECT5") || n.getNodeName().equals("SECT6") || n.getNodeName().equals("SECT7")) return FILTER_SKIP; } return FILTER_REJECT; } }
This filter assumes that TABLE elements are contained directly in CHAPTER or SECTn elements. If another kind of element is encountered, it and its children are rejected. If a SECTn element is encountered, it is skipped, but its children are explored to see if they contain any TABLE elements.
Now the program can create an instance of this Filter, create a
TreeWalker
that uses it, and pass this TreeWalker
to
our ProcessMe() function:
TablesInChapters tablesInChapters = new TablesInChapters(); TreeWalker tw = ((DocumentTraversal)document).createTreeWalker(root, NodeFilter.SHOW_ELEMENT, tablesInChapters); processMe(tw);
(Again, we've chosen to both test the nodeType in the filter's logic and use SHOW_ELEMENT, for the reasons discussed in the earlier NodeIterator example.)
Without making any changes to the above ProcessMe() function, it now
processes only the CHAPTER and TABLE elements. The programmer can write other
filters or set other flags to choose different sets of nodes; if functions use
TreeWalker
to navigate, they will support any view of the document
defined with a TreeWalker
.
Note that the structure of a TreeWalker
's filtered view of a
document may differ significantly from that of the document itself. For
example, a TreeWalker
with only SHOW_TEXT specified in its
whatToShow parameter would present all the Text Nodes as if they were siblings
of each other yet had no parent.
As with iterators, a TreeWalker
may be active while the data
structure it navigates is being edited, and must behave gracefully in the face
of change. Additions and removals in the underlying data structure do not
invalidate a TreeWalker
; in fact, a TreeWalker
is
never invalidated.
But a TreeWalker
's response to these changes is quite different
from that of a NodeIterator
. While NodeIterator
s
respond to editing by maintaining their position within the subtree that they
are iterating over, TreeWalker
s will instead remain attached to
their currentNode. All the TreeWalker
's navigation methods operate
in terms of the context of the currentNode at the time they are invoked, no
matter what has happened to, or around, that node since the last time the
TreeWalker
was accessed. This remains true even if the currentNode
is moved out of its original subtree.
As an example, consider the following document fragment:
... <subtree> <twRoot> <currentNode/> <anotherNode/> </twRoot> </subtree> ...
Let's say we have created a TreeWalker
whose root node is the
<twRoot/> element and whose currentNode is the <currentNode/>
element. For this illustration, we will assume that all the nodes shown above
are accepted by the TreeWalker
's whatToShow and filter
settings.
If we use removeChild() to remove the <currentNode/> element from its
parent, that element remains the TreeWalker
's currentNode, even
though it is no longer within the root node's subtree. We can still use the
TreeWalker
to navigate through any children that the orphaned
currentNode may have, but are no longer able to navigate outward from the
currentNode since there is no parent available.
If we use insertBefore() or appendChild() to give the <currentNode/> a
new parent, then TreeWalker
navigation will operate from the
currentNode's new location. For example, if we inserted the <currentNode>
immediately after the <anotherNode/> element, the
TreeWalker
's previousSibling() operation would move it back to the
<anotherNode/>, and calling parentNode() would move it up to the
<twRoot/>.
If we instead insert the currentNode into the <subtree/> element, like so:
... <subtree> <currentNode/> <twRoot> <anotherNode/> </twRoot> </subtree> ...
we have moved the currentNode out from under the TreeWalker
's
root node. This does not invalidate the TreeWalker; it may still be used to
navigate relative to the currentNode. Calling its parentNode() operation, for
example, would move it to the <subtree/> element, even though that too is
outside the original root node. However, if the TreeWalker's navigation should
take it back into the original root node's subtree -- for example, if rather
than calling parentNode() we called nextNode(), moving the TreeWalker to the
<twRoot/> element -- the root node will "recapture" the TreeWalker, and
prevent it from traversing back out.
This becomes a bit more complicated when filters are in use. Relocation of the currentNode -- or explicit selection of a new currentNode, or changes in the conditions that the filter is basing its decisions on -- can result in a TreeWalker having a currentNode which would not otherwise be visible in the filtered view of the document. This node can be thought of as a "transient member" of that view. When you ask the TreeWalker to navigate off this node the result will be just as if it had been visible, but you may be unable to navigate back to it unless conditions change to make it visible again.
In particular: If the currentNode becomes part of a subtree that would otherwise have been Rejected by the filter, that entire subtree may be added as transient members of the logical view. You will be able to navigate within that subtree (subject to all the usual filtering) until you move upward past the Rejected ancestor. The behavior is as if the Rejected node had only been Skipped (since we somehow wound up inside its subtree) until we leave it; thereafter, standard filtering applies.
NodeIterators are used to step through a set of nodes, e.g. the set of nodes in a NodeList, the document subtree governed by a particular node, the results of a query, or any other set of nodes. The set of nodes to be iterated is determined by the implementation of the NodeIterator. DOM Level 2 specifies a single NodeIterator implementation for document-order traversal of a document subtree. Instances of these iterators are created by calling DocumentTraversal.createNodeIterator().
// Introduced in DOM Level 2: interface NodeIterator { readonly attribute Node root; readonly attribute unsigned long whatToShow; readonly attribute NodeFilter filter; readonly attribute boolean expandEntityReferences; Node nextNode() raises(DOMException); Node previousNode() raises(DOMException); void detach(); };
expandEntityReferences
of type boolean
, readonly
filter
of type NodeFilter
, readonly
root
of type Node
, readonly
whatToShow
of type unsigned long
, readonlyNodeFilter
interface.
Nodes not accepted by whatToShow will be skipped, but their children may still
be considered. Note that this skip takes precedence over the filter, if any.
detach
detach
has been invoked, calls to nextNode
or
previousNode
will raise the exception INVALID_STATE_ERR.nextNode
INVALID_STATE_ERR: Raised if this method is called after the
|
previousNode
INVALID_STATE_ERR: Raised if this method is called after the
|
Filters are objects that know how to "filter out" nodes. If a
NodeIterator
or TreeWalker
is given a filter, it
applies the filter before it returns the next node. If the filter says to
accept the node, the iterator returns it; otherwise, the iterator looks for the
next node and pretends that the node that was rejected was not there.
The DOM does not provide any filters. Filter is just an interface that users can implement to provide their own filters.
Filters do not need to know how to iterate, nor do they need to know anything about the data structure that is being iterated. This makes it very easy to write filters, since the only thing they have to know how to do is evaluate a single node. One filter may be used with a number of different kinds of iterators, encouraging code reuse.
Note: This is an ECMAScript function reference. This method returns a
short
. The parameter is of type Node
.
// Introduced in DOM Level 2: interface NodeFilter { // Constants returned by acceptNode const short FILTER_ACCEPT = 1; const short FILTER_REJECT = 2; const short FILTER_SKIP = 3; // Constants for whatToShow const unsigned long SHOW_ALL = 0xFFFFFFFF; const unsigned long SHOW_ELEMENT = 0x00000001; const unsigned long SHOW_ATTRIBUTE = 0x00000002; const unsigned long SHOW_TEXT = 0x00000004; const unsigned long SHOW_CDATA_SECTION = 0x00000008; const unsigned long SHOW_ENTITY_REFERENCE = 0x00000010; const unsigned long SHOW_ENTITY = 0x00000020; const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x00000040; const unsigned long SHOW_COMMENT = 0x00000080; const unsigned long SHOW_DOCUMENT = 0x00000100; const unsigned long SHOW_DOCUMENT_TYPE = 0x00000200; const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x00000400; const unsigned long SHOW_NOTATION = 0x00000800; short acceptNode(in Node n); };
The following constants are returned by the acceptNode() method:
FILTER_ACCEPT |
Accept the node. Navigation methods defined for NodeIterator or
TreeWalker will return this node. |
FILTER_REJECT |
Reject the node. Navigation methods defined for NodeIterator or
TreeWalker will not return this node. For TreeWalker ,
the children of this node will also be rejected. Iterators treat this as a
synonym for FILTER_SKIP. |
FILTER_SKIP |
Skip this single node. Navigation methods defined for
NodeIterator or TreeWalker will not return this node.
For both NodeIterator and Treewalker, the children of this node will still be
considered. |
These are the available values for the whatToShow parameter used in TreeWalkers and Iterators. They are the same as the set of possible types for Node, and their values are derived by using a bit position corresponding to the value of Node.nodeType for the equivalent node type. If a bit in whatToShow is set false, that will be taken as a request to skip over this type of node; the behavior in that case is similar to that of FILTER_SKIP.
Note that if node types greater than 32 are ever introduced, they may not be individually testable via whatToShow. If that need should arise, it can be handled by selecting SHOW_ALL together with an appropriate NodeFilter.
SHOW_ALL | Show all nodes. |
SHOW_ATTRIBUTE | Show attribute nodes. This is meaningful only when creating an iterator or tree-walker with an attribute node as its root; in this case, it means that the attribute node will appear in the first position of the iteration or traversal. Since attributes are not part of the document tree, they do not appear when traversing over the document tree. |
SHOW_CDATA_SECTION | Show CDATASection nodes. |
SHOW_COMMENT | Show Comment nodes. |
SHOW_DOCUMENT | Show Document nodes. |
SHOW_DOCUMENT_FRAGMENT | Show DocumentFragment nodes. |
SHOW_DOCUMENT_TYPE | Show DocumentType nodes. |
SHOW_ELEMENT | Show element nodes. |
SHOW_ENTITY | Show Entity nodes. This is meaningful only when creating an iterator or tree-walker with an Entity node as its root; in this case, it means that the Entity node will appear in the first position of the traversal. Since entities are not part of the document tree, they do not appear when traversing over the document tree. |
SHOW_ENTITY_REFERENCE | Show Entity Reference nodes. |
SHOW_NOTATION | Show Notation nodes. This is meaningful only when creating an iterator or tree-walker with a Notation node as its root; in this case, it means that the Notation node will appear in the first position of the traversal. Since notations are not part of the document tree, they do not appear when traversing over the document tree. |
SHOW_PROCESSING_INSTRUCTION | Show ProcessingInstruction nodes. |
SHOW_TEXT | Show text nodes. |
acceptNode
| The node to check to see if it passes the filter or not. |
|
a constant to determine whether the node is accepted, rejected, or skipped, as defined above. |
TreeWalker
objects are used to navigate a document tree or
subtree using the view of the document defined by its whatToShow
flags and any filters that are defined for the TreeWalker
. Any
function which performs navigation using a TreeWalker
will
automatically support any view defined by a TreeWalker
.
Omitting nodes from the logical view of a subtree can result in a structure that is substantially different from the same subtree in the complete, unfiltered document. Nodes that are siblings in the TreeWalker view may be children of different, widely separated nodes in the original view. For instance, consider a Filter that skips all nodes except for Text nodes and the root node of a document. In the logical view that results, all text nodes will be siblings and appear as direct children of the root node, no matter how deeply nested the structure of the original document.
// Introduced in DOM Level 2: interface TreeWalker { readonly attribute Node root; readonly attribute unsigned long whatToShow; readonly attribute NodeFilter filter; readonly attribute boolean expandEntityReferences; attribute Node currentNode; // raises(DOMException) on setting Node parentNode(); Node firstChild(); Node lastChild(); Node previousSibling(); Node nextSibling(); Node previousNode(); Node nextNode(); };
currentNode
of type Node
NOT_SUPPORTED_ERR: Raised if the specified |
expandEntityReferences
of type boolean
, readonly
filter
of type NodeFilter
, readonly
root
of type Node
, readonly
whatToShow
of type unsigned long
, readonlyNodeFilter
interface. Nodes not accepted by
whatToShow will be skipped, but their children may still be considered. Note
that this skip takes precedence over the filter, if any.
firstChild
TreeWalker
to the first visible child of the current
node, and returns the new node. If the current node has no visible children,
returns null
, and retains the current node.
The new node, or |
lastChild
TreeWalker
to the last visible child of the current
node, and returns the new node. If the current node has no visible children,
returns null
, and retains the current node.
The new node, or |
nextNode
TreeWalker
to the next visible node in document order
relative to the current node, and returns the new node. If the current node has
no next node, or if the search for nextNode attempts to step upward from the
TreeWalker's root node, returns null
, and retains the current
node.
The new node, or |
nextSibling
TreeWalker
to the next sibling of the current node,
and returns the new node. If the current node has no visible next sibling,
returns null
, and retains the current node.
The new node, or |
parentNode
The new parent node, or null if the current node has no parent in the TreeWalker's logical view. |
previousNode
TreeWalker
to the previous visible node in document
order relative to the current node, and returns the new node. If the current
node has no previous node,
or if the search for previousNode attempts to step upward from the TreeWalker's
root node,
returns null
, and retains the current node.
The new node, or |
previousSibling
TreeWalker
to the previous sibling of the current
node, and returns the new node. If the current node has no visible previous
sibling, returns null
, and retains the current node.
The new node, or |
DocumentTraversal
contains methods that create iterators and
tree-walkers to traverse a node and its children in document order (depth
first, pre-order traversal, which is equivalent to the order in which the start
tags occur in the text representation of the document). In DOMs which support
the Traversal feature, DocumentTraversal will be implemented by the same
objects that implement the Document interface.
// Introduced in DOM Level 2: interface DocumentTraversal { NodeIterator createNodeIterator(in Node root, in unsigned long whatToShow, in NodeFilter filter, in boolean entityReferenceExpansion); TreeWalker createTreeWalker(in Node root, in unsigned long whatToShow, in NodeFilter filter, in boolean entityReferenceExpansion) raises(DOMException); };
createNodeIterator
| 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. | |||
|
| This flag specifies which node types may appear in the logical view of the tree presented by the iterator. See the description of iterator for the set of possible values. These flags can be combined using | ||
| The Filter to be used with this TreeWalker, or null to indicate no filter. | |||
|
| The value of this flag determines whether entity reference nodes are expanded. |
The newly created |
createTreeWalker
| The node which will serve as the root for the | |||
|
| This flag specifies which node types may appear in the logical view of the tree presented by the iterator. See the description of TreeWalker for the set of possible values. These flags can be combined using | ||
| The Filter to be used with this TreeWalker, or null to indicate no filter. | |||
|
| The value of this flag determines whether entity reference nodes are expanded. |
The newly created |
Raises the exception NOT_SUPPORTED_ERR if the specified root node is null. |
A Range identifies a range of content in a Document, DocumentFragment or Attr. It is contiguous in the sense that it can be characterized as selecting all of the content between a pair of boundary-points.
Note: In a text editor or a word processor, a user can make a selection by pressing down the mouse at one point in a document, moving the mouse to another point, and releasing the mouse. The resulting selection is contiguous and consists of the content between the two points.
The term 'selecting' does not mean that every Range corresponds to a selection made by a GUI user; however, such a selection can be returned to a DOM user as a Range.
Note: In bidirectional writing (Arabic, Hebrew), a range may correspond to a logical selection that is not necessarily contiguous when displayed. A visually contiguous selection, also used in some cases, may not correspond to a single logical selection, and may therefore have to be represented by more than one range.
The Range interface provides methods for accessing and manipulating the document tree at a higher level than similar methods in the Node interface. The expectation is that each of the methods provided by the Range interface for the insertion, deletion and copying of content can be directly mapped to a series of Node editing operations enabled by DOM Core. In this sense, the Range operations can be viewed as convenience methods that also enable the implementation to optimize common editing patterns.
This chapter describes the Range interface, including methods for creating and moving a Range and methods for manipulating content with Ranges. The feature string for the interfaces listed in this section is "Range".
This chapter refers to two different representations of a document: the text or source form that includes the document markup and the tree representation similar to the one described in the What is the Document Object Model? section.
A Range consists of two boundary-points corresponding to the start and the end of the Range. A boundary-point's position in a document or document fragment tree can be characterized by a node and an offset. The node is called the container of the boundary-point and of its position. The container and its ancestors are the ancestor containers of the boundary-point and of its position. The offset within the node is called the offset of the boundary-point and its position. If the container is an Attr, Document, Document Fragment, Element or EntityReference node, the offset is between its child nodes. If the container is a CharacterData, Comment or ProcessingInstruction node, the offset is between the 16-bit units of the UTF-16 encoded string contained by it.
The boundary-points of a Range must have a common ancestor container which is either a Document, DocumentFragment or Attr node. That is, the content of a Range must be entirely within the subtree rooted by a single Document, DocumentFragment or Attr Node. This common ancestor container is known as the root container of the Range. The tree rooted by the root container is known as the Range's context tree.
The container of an boundary-point of a Range must be an Element, Comment, ProcessingInstruction, EntityReference, CDATASection, Document, DocumentFragment, Attr, or Text node. None of the ancestor containers of the boundary-point of a Range can be a DocumentType, Entity or Notation node.
In terms of the text representation of a document, the boundary-points of a Range can only be on token boundaries. That is, the boundary-point of the text range cannot be in the middle of a start- or end-tag of an element or within the name of an entity or character reference. A Range locates a contiguous portion of the content of the structure model.
The relationship between locations in a text
representation of the document and in the Node tree
interface of the DOM is illustrated in the following
diagram:
In this diagram, four different Ranges are illustrated. The boundary-points of each range are labelled with s# (the start of the range) and e# (the end of the range), where # is the number of the Range. For Range 2, the start is in the BODY element and is immediately after the H1 element and immediately before the P element, so its position is between the H1 and P children of BODY. The offset of a boundary-point whose container is not a CharacterData node is 0 if it is before the first child, 1 if between the first and second child, and so on. So, for the start of the Range 2, the container is BODY and the offset is 1. The offset of a boundary-point whose container is a CharacterData node is obtained similarly but using 16-bit unit positions instead. For example, the boundary-point labelled s1 of the Range 1 has a Text node (the one containing "Title") as its container and an offset of 2 since it is between the second and third 16-bit unit.
Notice that the boundary-points of Ranges 3 and 4 correspond to the same location in the text representation. An important feature of the Range is that a boundary-point of a Range can unambiguously represent every position within the document tree.
The containers and offsets of the boundary-points can be obtained through the following read-only Range attributes:
readonly attribute Node startContainer; readonly attribute long startOffset; readonly attribute Node endContainer; readonly attribute long endOffset;
If the boundary-points of a Range have the same containers and offsets, the Range is said to be a collapsed Range. (This is often referred to as an insertion point in a user agent.)
A node or 16-bit unit is said to be selected by a Range if it is between the two boundary-points of the Range, that is, if the position immediately before the node or 16-bit unit is before the end of the Range and the position immediately after the node or 16-bit unit is after the start of the range. For example, in terms of a text representation of the document, an element would be selected by a Range if its corresponding start-tag was located after the start of the Range and its end-tag was located before the end of the Range. In the examples in the above diagram, the Range 2 selects the P node and the Range 3 selects the text node containing the text "Blah xyz."
A node is said to be partially selected by a Range if it is an ancestor container of exactly one boundary-point of the Range. For example, consider Range 1 in the above diagram. The element H1 is partially selected by that Range since the start of the Range is within one of its children.
Many of the examples in this chapter are illustrated using a text representation of a document. The boundary-points of a range are indicated by displaying the characters (be they markup or data characters) between the two boundary-points in bold, as in
<FOO>ABC<BAR>DEF</BAR></FOO>
When both boundary-points are at the same position, they are indicated with a bold caret ('^'), as in
<FOO>A^BC<BAR>DEF</BAR></FOO>
And when referring to a single boundary-point, it will be shown as a bold asterisk ('*') as in
<FOO>A*BC<BAR>DEF</BAR></FOO>
A range is created by calling the createRange()
method on the DocumentRange
interface. This
interface can be obtained from the object implementing the
Document
interface using binding-specific casting methods.
interface DocumentRange { Range createRange(); }
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. In other words, the container of each boundary-point is the Document node and the offset within that node is 0.
Like some objects created using methods in the Document
interface (such as Nodes and DocumentFragments),
Ranges created via a particular document instance can
select only content associated with that
Document, or with DocumentFragments and Attrs for which
that Document is the ownerDocument
. Such
Ranges, then, can not be used with other Document
instances.
A Range's position can be specified by setting the
container and offset of each boundary-point with the
setStart
and setEnd
methods.
void setStart(in Node parent, in long offset) raises(RangeException); void setEnd(in Node parent, in long offset) raises(RangeException);
If one boundary-point of a Range is set to have a root container other than the current one for the range, the range is collapsed to the new position. This enforces the restriction that both boundary-points of a Range must have the same root container.
The start position of a Range is guaranteed to never be after the end position. To enforce this restriction, if the start is set to be at a position after the end, the range is collapsed to that position. Similarly, if the end is set to be at a position before the start, the range is collapsed to that position.
It is also possible to set a Range's position relative to nodes in the tree:
void setStartBefore(in Node node); raises(RangeException); void setStartAfter(in Node node); raises(RangeException); void setEndBefore(in Node node); raises(RangeException); void setEndAfter(in Node node); raises(RangeException);
The parent of the node becomes the container of the boundary-point and the Range is
subject to the same restrictions as given above in the
description of setStart()
and
setEnd()
.
A Range can be collapsed to either boundary-point:
void collapse(in boolean toStart);
Passing TRUE
as the parameter
toStart
will collapse the Range to its
start , FALSE
to its end.
Testing whether a Range is collapsed can be done by examining the
collapsed
attribute:
readonly attribute boolean collapsed;
The following methods can be used to make a range select the contents of a node or the node itself.
void selectNode(in Node n); void selectNodeContents(in Node n);
The following examples demonstrate the operation of the methods
selectNode
and selectNodeContents
:
Before: ^<BAR><FOO>A<MOO>B</MOO>C</FOO></BAR> After range.selectNodeContents(FOO): <BAR><FOO>A<MOO>B</MOO>C</FOO></BAR> (In this case, FOO is the parent of both boundary-points) After range.selectNode(FOO): <BAR><FOO>A<MOO>B</MOO>C</FOO></BAR>
It is possible to compare two Ranges by comparing their boundary-points:
int compareBoundaryPoints(in CompareHow how, in Range sourceRange) raises(RangeException);
where CompareHow
is one of four values:
START_TO_START
, START_TO_END
,
END_TO_END
and END_TO_START
. The
return value is -1, 0 or 1 depending on whether the
corresponding boundary-point of the Range is before, equal
to, or after the corresponding boundary-point of
sourceRange
. An exception is thrown if
the two Ranges have different root containers.
The result of comparing two boundary-points (or positions) is specified below. An informal but not always correct specification is that an boundary-point is before, equal to, or after another if it corresponds to a location in a text representation before, equal to, or after the other's corresponding location.
Let A and B be two boundary-points or positions. Then one of the following holds: A is before B, A is equal to B, or A is after B. Which one holds is specified in the following by examining four cases:
In the first case the boundary-points have the same container. A is before B if its offset is less than the offset of B, A is equal to B if its offset is equal to the offset of B, and A if after B if its offset is greater than the offset of B.
In the second case a child C of the container of A is an ancestor container of B. In this case, A is before B if the offset of A is less than or equal to the index of the child C and A is after B otherwise.
In the third case a child C of the container of B is an ancestor container of A. In this case, A is before B if the index of the child C is less than the offset of B and A is after B otherwise.
In the fourth case, none of three other cases hold: the containers of A and B are siblings or descendants of sibling nodes. In this case, A is before B if the container of A is before the container of B in a pre-order traversal of the Ranges' context tree and A is after B otherwise.
Note that because the same location in a text representation of the document can correspond to two different positions in the DOM tree, it is possible for two boundary-points to not compare equal even though they would be equal in the text representation. For this reason, the informal definition above can sometimes be incorrect.
One can delete the contents selected by a Range with:
void deleteContents();
deleteContents()
deletes all nodes and
characters selected by the Range. All other nodes and
characters remain in the context tree of the
Range. Some examples of this deletion operation are:
(1) <FOO>AB<MOO>CD</MOO>CD</FOO> --> <FOO>A^CD</FOO>
(2) <FOO>A<MOO>BC</MOO>DE</FOO> --> <FOO>A<MOO>B</MOO>^E</FOO>
(3) <FOO>XY<BAR>ZW</BAR>Q</FOO> --> <FOO>X^<BAR>W</BAR>Q</FOO>
(4) <FOO><BAR1>AB</BAR1><BAR2/><BAR3>CD</BAR3></FOO> --> <FOO><BAR1>A</BAR1>^<BAR3>D</BAR3>
After deleteContents()
is invoked on a Range,
the Range is collapsed. If no node was
partially
selected by the Range, then it is collapsed to its original
start point, as in example (1). If a node was partially
selected by the Range and was an ancestor
container of the start of the Range and no
ancestor of the node satisfies these two conditions,
then the Range is collapsed to the position
immediately after the node, as in examples (2) and
(4). If a node waspartially
selected by the Range and was an ancestor
container of the end of the Range and no
ancestor of the node satisfies these two conditions,
then the Range is collapsed to the position
immediately before the node, as in examples (3) and
(4).
If the contents of a range need to be extracted rather than deleted, the following method may be used:
DocumentFragment extractContents();
The extractContents()
method removes nodes
from the Range's context
tree similarly to the deleteContents()
method. In addition, it places the deleted contents in a new
DocumentFragment. The following examples illustrate the
contents of the returned document fragment:
(1) <FOO>AB<MOO>CD</MOO>CD</FOO> --> B<MOO>CD</MOO>
(2) <FOO>A<MOO>BC</MOO>DE</FOO> --> <MOO>C<MOO>D
(3) <FOO>XY<BAR>ZW</BAR>Q</FOO> --> Y<BAR>Z</BAR>
(4) <FOO><BAR1>AB</BAR1><BAR2/><BAR3>CD</BAR3></FOO> --> <BAR1>B</BAR1><BAR2/><BAR3>C</BAR3>
It is important to note that nodes that are partially selected by the range are cloned. Since part of such a node's contents must remain in the Range's context tree and part of the contents must be moved to the new fragment, a clone of the partially selected node is included in the new fragment. Note that cloning does not take place for selected elements; these nodes are moved to the new fragment.
The contents of a range may be duplicated using the following method:
DocumentFragment cloneContents();
This method returns a DocumentFragment that is similar to
the one returned by the method
extractContents()
. However, in this case,
the original nodes and character data in the Range are
not removed from the Range's context tree. Instead,
all of the nodes and text content within the returned
DocumentFragment are cloned.
A node may be inserted into a range using the following method:
void insertNode(in Node n) raises(RangeException);
The insertNode()
method inserts the specified
node into the Range's context tree. For this
method, the end of the range is ignored and the node
is inserted at the start of the range.
The Node passed into this method can be a DocumentFragment. In that case, the contents of the fragment are inserted at the start position of the range, but the fragment itself is not. Note that if the Node represents the root of a sub-tree, the entire sub-tree is inserted.
The same rules that apply to the
insertBefore()
method on the Node
interface apply here. Specifically, the Node passed in,
if it already has a parent,
will be removed from its existing position.
The insertion of a single node to subsume the content selected by a Range can be performed with:
void surroundContents(in Node n);
The surroundContents()
method causes all of
the content selected by the range to be rooted by the
specified node. Calling
surroundContents()
with the node FOO in
the following examples yields:
Before: <BAR>AB<MOO>C</MOO>DE</BAR> After surroundContents(FOO): <BAR>A<FOO>B<MOO>C</MOO>D</FOO>E</BAR>
Another way of describing the effect of this method on the Range's context tree is to decompose it in terms of other operations:
extractContents()
.node
where the range is now
collapsed (after the extraction) with insertNode()
node
. Specifically, invoke the
appendChild()
on
node
passing in the
DocumentFragment returned as a result of the
call to extractContents()
node
and all of its contents with
selectNode()
.The surroundContents()
method raises an
exception if the range partially
selects a non-Text node. An example of a
range for which surroundContents()
raises
an exception is:
<FOO>AB<BAR>CD</BAR>E</FOO>
If node
has any children, those children are
removed before its insertion. Also, if
node
already has a parent, it
is removed from the original parent's childNodes
list.
One can clone a Range:
Range cloneRange();
This creates a new Range which selects exactly the same
content as that selected by the Range on which the
method cloneRange
was invoked. No content
is affected by this operation.
Because the boundary-points of a range do not necessarily have the same containers, use:
readonly attribute Node commonAncestorContainer;
to get the ancestor container of both boundary-points that is furthest down from the Range's root container
One can get a copy of all the character data selected or partially selected by a range with:
DOMString toString();
This does nothing more than simply concatenate all the character
data selected by the range. This includes character data
in both Text
and CDATASection
nodes.
As a document is modified, the Ranges within the document need to be updated. For example, if one boundary-point of a Range is within a node and that node is removed from the document, then the Range would be invalid unless it is fixed up in some way. This section describes how Ranges are modified under document mutations so that they remain valid.
There are two general principles which apply to Ranges under document mutation: The first is that all Ranges in a document will remain valid after any mutation operation and the second is that, as much as possible, all Ranges will select the same portion of the document after any mutation operation.
Any mutation of the document tree which affect Ranges can
be considered to be a combination of basic delete and
insertion operations. In fact, it can be convenient to
think of those operations as being accomplished using
the deleteContents()
and
insertNode()
Range methods.
An insertion occurs at a single point, the insertion point, in the document. For any Range in the document tree, consider each boundary-point. The only case in which the boundary-point will be changed after the insertion is when the boundary-point and the insertion point have the same container and the offset of the insertion point is strictly less than the offset of the Range's boundary-point. In that case the offset of the Range's boundary-point will be increased so that it is between the same nodes or characters as it was before the insertion.
Note that when content is inserted at a boundary-point, it is ambiguous as to where the boundary-point should be repositioned if its relative position is to be maintained. There are two possibilities: at the start or at the end of the newly inserted content. We have chosen that in this case neither the container nor offset of the boundary-point is changed. As a result, it will be positioned at the start of the newly inserted content.
Examples:
Suppose the Range selects the following:
<P>Abcd efgh XY blah ijkl</P>
Consider the insertion of the text "inserted text" at the following positions:
1. Before the 'X': <P>Abcd efgh inserted textXY blah ijkl</P> 2. After the 'X': <P>Abcd efgh Xinserted textY blah ijkl</P> 3. After the 'Y': <P>Abcd efgh XYinserted text blah ijkl</P> 4. After the 'h' in "Y blah": <P>Abcd efgh XY blahinserted text ijkl</P>
Any deletion from the document tree can be considered as a sequence
of
deleteContents()
operations applied to a minimal set of
disjoint
Ranges. To specify how a Range is modified under deletions we need
only to
consider what happens to a Range under a single
deleteContents()
operation of another Range. And, in
fact, we need
only to consider what happens to a single boundary-point of the Range since
both
boundary-points are modified using the same algorithm.
If a boundary-point is within the content being deleted, then after the deletion it will be at the same position as the one common to the boundary-points of the Range used to delete the contents.
If a boundary-point is after the content being deleted then it is not affected by the deletion unless its container is also the container of one of the boundary-points of the range being deleted. If there is such a common container, then the index of the boundary-point is modified so that the boundary-point maintains its position relative to the content of the container.
If a boundary-point is before the content being deleted then it is not affected by the deletion at all.
Examples:
In these examples, the Range on which deleteContents()
is
invoked is indicated by the underline.
Example 1.
Before:
<P>Abcd efgh The Range ijkl</P>
After:
<P>Abcd Range ijkl</P>
Example 2.
Before:
<p>Abcd efgh The Range ijkl</p>
After:
<p>Abcd ^kl</p>
Example 3.
Before:
<P>ABCD efgh The <EM>Range</EM> ijkl</P>
After:
<P>ABCD <EM>ange</EM> ijkl</P>
In this example, the container of the start boundary-point after the deletion is the Text node holding the string "ange".
Example 4.
Before:
<P>Abcd efgh The Range ijkl</P>
After:
<P>Abcd he Range ijkl</P>
Example 5.
Before:
<P>Abcd <EM>efgh The Range ij</EM>kl</P>
After:
<P>Abcd ^kl</P>
To summarize, the complete, formal description of the Range
interface is given below:
// Introduced in DOM Level 2: interface Range { readonly attribute Node startContainer; // raises(DOMException) on retrieval readonly attribute long startOffset; // raises(DOMException) on retrieval readonly attribute Node endContainer; // raises(DOMException) on retrieval readonly attribute long endOffset; // raises(DOMException) on retrieval readonly attribute boolean collapsed; // raises(DOMException) on retrieval readonly attribute Node commonAncestorContainer; // raises(DOMException) on retrieval void setStart(in Node refNode, in long offset) raises(RangeException, DOMException); void setEnd(in Node refNode, in long offset) raises(RangeException, DOMException); void setStartBefore(in Node refNode) raises(RangeException, DOMException); void setStartAfter(in Node refNode) raises(RangeException, DOMException); void setEndBefore(in Node refNode) raises(RangeException, DOMException); void setEndAfter(in Node refNode) raises(RangeException, DOMException); void collapse(in boolean toStart) raises(DOMException); void selectNode(in Node refNode) raises(RangeException, DOMException); void selectNodeContents(in Node refNode) raises(RangeException, DOMException); // CompareHow const unsigned short START_TO_START = 0; const unsigned short START_TO_END = 1; const unsigned short END_TO_END = 2; const unsigned short END_TO_START = 3; short compareBoundaryPoints(in unsigned short how, in Range sourceRange) raises(DOMException); void deleteContents() raises(DOMException); DocumentFragment extractContents() raises(DOMException); DocumentFragment cloneContents() raises(DOMException); void insertNode(in Node newNode) raises(DOMException, RangeException); void surroundContents(in Node newParent) raises(DOMException, RangeException); Range cloneRange() raises(DOMException); DOMString toString() raises(DOMException); void detach() raises(DOMException); };
Passed as a parameter to the
compareBoundaryPoints
method.
END_TO_END |
Compare end boundary-point of
sourceRange to end boundary-point of Range on which compareBoundaryPoints is invoked. |
END_TO_START |
Compare end boundary-point of
sourceRange to start boundary-point of Range on which compareBoundaryPoints is invoked. |
START_TO_END |
Compare start boundary-point of
sourceRange to end boundary-point of Range on which compareBoundaryPoints is invoked. |
START_TO_START |
Compare start boundary-point of
sourceRange to start boundary-point of Range on which compareBoundaryPoints is invoked. |
collapsed
of type boolean
, readonly
INVALID_STATE_ERR: Raised if |
commonAncestorContainer
of type Node
, readonly
INVALID_STATE_ERR: Raised if |
endContainer
of type Node
, readonly
INVALID_STATE_ERR: Raised if |
endOffset
of type long
, readonly
INVALID_STATE_ERR: Raised if |
startContainer
of type Node
, readonly
INVALID_STATE_ERR: Raised if |
startOffset
of type long
, readonly
INVALID_STATE_ERR: Raised if |
cloneContents
A DocumentFragment containing contents equivalent to those of this range. |
HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be extracted into the new DocumentFragment. INVALID_STATE_ERR: Raised if |
cloneRange
The duplicated range. |
INVALID_STATE_ERR: Raised if |
collapse
|
| If TRUE, collapses the Range onto its start; if FALSE, collapses it onto its end. |
INVALID_STATE_ERR: Raised if |
compareBoundaryPoints
|
| |||
|
|
-1, 0 or 1 depending on whether the corresponding
boundary-point
of the Range is before, equal to, or after the
corresponding boundary-point of
|
WRONG_DOCUMENT_ERR: Raised if the two Ranges are not in the same document or document fragment. INVALID_STATE_ERR: Raised if |
deleteContents
NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the content of the range is read-only or any of the nodes that contain any of the content of the range are read-only. INVALID_STATE_ERR: Raised if |
detach
DOMException
being
thrown with an error code of
INVALID_STATE_ERR
.
INVALID_STATE_ERR: Raised if |
extractContents
A DocumentFragment containing the extracted contents. |
NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the content of the range is read-only or any of the nodes which contain any of the content of the range are read-only. HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be extracted into the new DocumentFragment. INVALID_STATE_ERR: Raised if |
insertNode
| The node to insert at the start of the range |
NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of the start of the range is read-only. WRONG_DOCUMENT_ERR: Raised if
HIERARCHY_REQUEST_ERR: Raised if the
container of the start of the Range is of
a type that does not allow children of
the type of INVALID_STATE_ERR: Raised if | ||
INVALID_NODE_TYPE_ERR: Raised if
|
selectNode
| The node to select. |
INVALID_NODE_TYPE_ERR: Raised if an ancestor
of
| ||
INVALID_STATE_ERR: Raised if |
selectNodeContents
| Node to select from |
INVALID_NODE_TYPE_ERR: Raised if
| ||
INVALID_STATE_ERR: Raised if |
setEnd
| The | |||
|
| The |
INVALID_NODE_TYPE_ERR: Raised if
| ||
INDEX_SIZE_ERR: Raised if INVALID_STATE_ERR: Raised if |
setEndAfter
| Range ends after |
INVALID_NODE_TYPE_ERR: Raised if the root container
of
| ||
INVALID_STATE_ERR: Raised if |
setEndBefore
| Range ends before |
INVALID_NODE_TYPE_ERR: Raised if the root container
of
| ||
INVALID_STATE_ERR: Raised if |
setStart
| The | |||
|
| The |
INVALID_NODE_TYPE_ERR: Raised if
| ||
INDEX_SIZE_ERR: Raised if INVALID_STATE_ERR: Raised if |
setStartAfter
| Range starts after |
INVALID_NODE_TYPE_ERR: Raised if the root container
of
| ||
INVALID_STATE_ERR: Raised if |
setStartBefore
| Range starts before |
INVALID_NODE_TYPE_ERR: Raised if the root container
of
| ||
INVALID_STATE_ERR: Raised if |
surroundContents
| The node to surround the contents with. |
NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of either boundary-point of the range is read-only. WRONG_DOCUMENT_ERR: Raised if
HIERARCHY_REQUEST_ERR: Raised if the
container of the start of the Range is of
a type that does not allow children of
the type of INVALID_STATE_ERR: Raised if | ||
BAD_BOUNDARYPOINTS_ERR: Raised if the range partially selects a non-text node. INVALID_NODE_TYPE_ERR: Raised if
|
toString
The contents of the range. |
INVALID_STATE_ERR: Raised if |
// Introduced in DOM Level 2: interface DocumentRange { Range createRange(); };
createRange
Document
interface using binding-specific
casting methods.
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 |
Range operations may throw a RangeException
as specified in their method descriptions.
// Introduced in DOM Level 2: exception RangeException { unsigned short code; }; // RangeExceptionCode const unsigned short BAD_BOUNDARYPOINTS_ERR = 1; const unsigned short INVALID_NODE_TYPE_ERR = 2;
An integer indicating the type of error generated.
BAD_BOUNDARYPOINTS_ERR | If the boundary-points of a range do not meet specific requirements. |
INVALID_NODE_TYPE_ERR | If the container of an boundary-point of a range is being set to either a node of an invalid type or a node with an ancestor of an invalid type. |
Attr
interface has one new
attribute: ownerElement
.Document
interface has five new methods:
importNode
, createElementNS
,
createAttributeNS
, getElementsByTagNameNS
and getElementById
.NamedNodeMap
interface has three new
methods: getNamedItemNS
, setNamedItemNS
,
removeNamedItemNS
.Node
interface has two new
methods: supports
and normalize
.Node
interface has three new attributes:
namespaceURI
, prefix
and
localName
.ownerDocument
attribute was specified to be
null
when the node is a Document
. It
now is also null
when the node is a
DocumentType
which is not used with any
Document
yet.DocumentType
interface has three attributes:
publicId
, systemId
and
internalSubset
.DOMImplementation
interface has two new
methods: createDocumentType
and
createDocument
.Element
interface has eight new
methods: getAttributeNS
,
setAttributeNS
, removeAttributeNS
,
getAttributeNodeNS
, setAttributeNodeNS
,
getElementsByTagNameNS
, hasAttribute
and hasAttributeNS
.normalize
is now inherited from
the Node
interface where it was moved.DOMException
has five new
exception codes: INVALID_STATE_ERR
,
SYNTAX_ERR
, INVALID_MODIFICATION_ERR
,
NAMESPACE_ERR
and INVALID_ACCESS_ERR
.HTMLDOMImplementation
interface was
added to the HTML module.HTMLDocument
interface, the method
getElementById
is now inherited from the
Document
interface where it was moved.HTMLFrameElement
,
HTMLIFrameElement
, and
HTMLObjectElement
interfaces the attribute
contentDocument
was added.AbstractView
and DocumentView
.StyleSheet
, StyleSheetList
,
MediaList
, DocumentStyle
and
LinkStyle
.CSS2Azimuth
,
CSS2BackgroundPosition
,
CSS2BorderSpacing
,
CSS2CounterIncrement
, CSS2CounterReset
,
CSS2Cursor
, CSS2FontFaceSrc
,
CSS2FontFaceWidths
, CSS2PageSize
,
CSS2PlayDuring
, CSS2Properties
,
CSS2TextShadow
, CSSCharsetRule
,
CSSFontFaceRule
, CSSImportRule
,
CSSMediaRule
, CSSPageRule
,
CSSPrimitiveValue
, CSSRule
,
CSSRuleList
, CSSStyleDeclaration
,
CSSStyleRule
, CSSStyleSheet
,
CSSUnknownRule
, CSSValue
,
CSSValueList
, Counter
,
RGBColor
, Rect
, ViewCSS
,
DocumentCSS
, DOMImplementationCSS
and
ElementCSSInlineStyle
.
Event
, EventListener
,
EventTarget
, DocumentEvent
,
MutationEvent
,
UIEvent
and MouseEvent
, and the
exception EventException
.NodeFilter
, NodeIterator
,
TreeWalker
, and DocumentTraversal
.Range
,
DocumentRange
and the exception
RangeException
.This appendix is an informative, not a normative, part of the Level 2 DOM specification.
Characters are represented in Unicode by numbers called code points (also called scalar values). These numbers can range from 0 up to 1,114,111 = 10FFFF16 (although some of these values are illegal). Each code point can be directly encoded with a 32-bit code unit. This encoding is termed UCS-4 (or UTF-32). The DOM specification, however, uses UTF-16, in which the most frequent characters (which have values less than FFFF16) are represented by a single 16-bit code unit, while characters above FFFF16 use a special pair of code units called a surrogate pair. For more information, see [Unicode] or the Unicode Web site.
While indexing by code points as opposed to code units is not
common in programs, some specifications such as XPath (and therefore XSLT
and XPointer) use code point
indices. For interfacing with such formats it is recommended
that the programming language provide string processing methods for
converting code point indices to code unit indices and back. Some
languages do not provide these functions natively; for these it is
recommended that the native String
type that is bound to
DOMString
be extended to enable this conversion. An example
of how such an API might look is supplied below.
Note: Since these methods are supplied as an illustrative example of the type of functionality that is required, the names of the methods, exceptions, and interface may differ from those given here.
Extensions to a language's native String class or interface
interface StringExtend { int findOffset16(in int offset32) raises(StringIndexOutOfBoundsException); int findOffset32(in int offset16) raises(StringIndexOutOfBoundsException); };
findOffset16
Note: You can always roundtrip from a UTF-32 offset to a UTF-16 offset and back. You can roundtrip from a UTF-16 offset to a UTF-32 offset and back if and only if the offset16 is not in the middle of a surrogate pair. Unmatched surrogates count as a single UTF-16 value.
|
| UTF-32 offset. |
|
UTF-16 offset |
|
if |
findOffset32
len32 = findOffset32(source, source.length());
Note: If the UTF-16 offset is into the middle of a surrogate pair, then the UTF-32 offset of the end of the pair is returned; that is, the index of the char after the end of the pair. You can always roundtrip from a UTF-32 offset to a UTF-16 offset and back. You can roundtrip from a UTF-16 offset to a UTF-32 offset and back if and only if the offset16 is not in the middle of a surrogate pair. Unmatched surrogates count as a single UTF-16 value.
|
| UTF-16 offset |
|
UTF-32 offset |
|
if offset16 is out of bounds. |
This appendix contains the complete OMG IDL for the Level 2 Document Object Model definitions. The definitions are divided into Core, HTML, Stylesheets, CSS, Events, TreeWalkers, Filters, and Iterators, and Range.
The IDL files are also available as: http://www.w3.org/TR/2000/CR-DOM-Level-2-20000307/idl.zip
// File: dom.idl #ifndef _DOM_IDL_ #define _DOM_IDL_ #pragma prefix "w3c.org" module dom { typedef sequence<unsigned short> DOMString; typedef unsigned long long DOMTimeStamp; interface DocumentType; interface Document; interface NodeList; interface NamedNodeMap; interface Element; exception DOMException { unsigned short code; }; // ExceptionCode const unsigned short INDEX_SIZE_ERR = 1; const unsigned short DOMSTRING_SIZE_ERR = 2; const unsigned short HIERARCHY_REQUEST_ERR = 3; const unsigned short WRONG_DOCUMENT_ERR = 4; const unsigned short INVALID_CHARACTER_ERR = 5; const unsigned short NO_DATA_ALLOWED_ERR = 6; const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7; const unsigned short NOT_FOUND_ERR = 8; const unsigned short NOT_SUPPORTED_ERR = 9; const unsigned short INUSE_ATTRIBUTE_ERR = 10; // Introduced in DOM Level 2: const unsigned short INVALID_STATE_ERR = 11; // Introduced in DOM Level 2: const unsigned short SYNTAX_ERR = 12; // Introduced in DOM Level 2: const unsigned short INVALID_MODIFICATION_ERR = 13; // Introduced in DOM Level 2: const unsigned short NAMESPACE_ERR = 14; // Introduced in DOM Level 2: const unsigned short INVALID_ACCESS_ERR = 15; interface DOMImplementation { boolean hasFeature(in DOMString feature, in DOMString version); // Introduced in DOM Level 2: DocumentType createDocumentType(in DOMString qualifiedName, in DOMString publicId, in DOMString systemId) raises(DOMException); // Introduced in DOM Level 2: Document createDocument(in DOMString namespaceURI, in DOMString qualifiedName, in DocumentType doctype) raises(DOMException); }; interface Node { // NodeType const unsigned short ELEMENT_NODE = 1; const unsigned short ATTRIBUTE_NODE = 2; const unsigned short TEXT_NODE = 3; const unsigned short CDATA_SECTION_NODE = 4; const unsigned short ENTITY_REFERENCE_NODE = 5; const unsigned short ENTITY_NODE = 6; const unsigned short PROCESSING_INSTRUCTION_NODE = 7; const unsigned short COMMENT_NODE = 8; const unsigned short DOCUMENT_NODE = 9; const unsigned short DOCUMENT_TYPE_NODE = 10; const unsigned short DOCUMENT_FRAGMENT_NODE = 11; const unsigned short NOTATION_NODE = 12; readonly attribute DOMString nodeName; attribute DOMString nodeValue; // raises(DOMException) on setting // raises(DOMException) on retrieval readonly attribute unsigned short nodeType; readonly attribute Node parentNode; readonly attribute NodeList childNodes; readonly attribute Node firstChild; readonly attribute Node lastChild; readonly attribute Node previousSibling; readonly attribute Node nextSibling; readonly attribute NamedNodeMap attributes; // Modified in DOM Level 2: readonly attribute Document ownerDocument; Node insertBefore(in Node newChild, in Node refChild) raises(DOMException); Node replaceChild(in Node newChild, in Node oldChild) raises(DOMException); Node removeChild(in Node oldChild) raises(DOMException); Node appendChild(in Node newChild) raises(DOMException); boolean hasChildNodes(); Node cloneNode(in boolean deep); // Introduced in DOM Level 2: void normalize(); // Introduced in DOM Level 2: boolean supports(in DOMString feature, in DOMString version); // Introduced in DOM Level 2: readonly attribute DOMString namespaceURI; // Introduced in DOM Level 2: attribute DOMString prefix; // raises(DOMException) on setting // Introduced in DOM Level 2: readonly attribute DOMString localName; }; interface NodeList { Node item(in unsigned long index); readonly attribute unsigned long length; }; interface NamedNodeMap { Node getNamedItem(in DOMString name); Node setNamedItem(in Node arg) raises(DOMException); Node removeNamedItem(in DOMString name) raises(DOMException); Node item(in unsigned long index); readonly attribute unsigned long length; // Introduced in DOM Level 2: Node getNamedItemNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: Node setNamedItemNS(in Node arg) raises(DOMException); // Introduced in DOM Level 2: Node removeNamedItemNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); }; interface CharacterData : Node { attribute DOMString data; // raises(DOMException) on setting // raises(DOMException) on retrieval readonly attribute unsigned long length; DOMString substringData(in unsigned long offset, in unsigned long count) raises(DOMException); void appendData(in DOMString arg) raises(DOMException); void insertData(in unsigned long offset, in DOMString arg) raises(DOMException); void deleteData(in unsigned long offset, in unsigned long count) raises(DOMException); void replaceData(in unsigned long offset, in unsigned long count, in DOMString arg) raises(DOMException); }; interface Attr : Node { readonly attribute DOMString name; readonly attribute boolean specified; attribute DOMString value; // raises(DOMException) on setting // Introduced in DOM Level 2: readonly attribute Element ownerElement; }; interface Element : Node { readonly attribute DOMString tagName; DOMString getAttribute(in DOMString name); void setAttribute(in DOMString name, in DOMString value) raises(DOMException); void removeAttribute(in DOMString name) raises(DOMException); Attr getAttributeNode(in DOMString name); Attr setAttributeNode(in Attr newAttr) raises(DOMException); Attr removeAttributeNode(in Attr oldAttr) raises(DOMException); NodeList getElementsByTagName(in DOMString name); // Introduced in DOM Level 2: DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: void setAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) raises(DOMException); // Introduced in DOM Level 2: void removeAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); // Introduced in DOM Level 2: Attr getAttributeNodeNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException); // Introduced in DOM Level 2: NodeList getElementsByTagNameNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: boolean hasAttribute(in DOMString name); // Introduced in DOM Level 2: boolean hasAttributeNS(in DOMString namespaceURI, in DOMString localName); }; interface Text : CharacterData { Text splitText(in unsigned long offset) raises(DOMException); }; interface Comment : CharacterData { }; interface CDATASection : Text { }; interface DocumentType : Node { readonly attribute DOMString name; readonly attribute NamedNodeMap entities; readonly attribute NamedNodeMap notations; // Introduced in DOM Level 2: readonly attribute DOMString publicId; // Introduced in DOM Level 2: readonly attribute DOMString systemId; // Introduced in DOM Level 2: readonly attribute DOMString internalSubset; }; interface Notation : Node { readonly attribute DOMString publicId; readonly attribute DOMString systemId; }; interface Entity : Node { readonly attribute DOMString publicId; readonly attribute DOMString systemId; readonly attribute DOMString notationName; }; interface EntityReference : Node { }; interface ProcessingInstruction : Node { readonly attribute DOMString target; attribute DOMString data; // raises(DOMException) on setting }; interface DocumentFragment : Node { }; interface Document : Node { readonly attribute DocumentType doctype; readonly attribute DOMImplementation implementation; readonly attribute Element documentElement; Element createElement(in DOMString tagName) raises(DOMException); DocumentFragment createDocumentFragment(); Text createTextNode(in DOMString data); Comment createComment(in DOMString data); CDATASection createCDATASection(in DOMString data) raises(DOMException); ProcessingInstruction createProcessingInstruction(in DOMString target, in DOMString data) raises(DOMException); Attr createAttribute(in DOMString name) raises(DOMException); EntityReference createEntityReference(in DOMString name) raises(DOMException); NodeList getElementsByTagName(in DOMString tagname); // Introduced in DOM Level 2: Node importNode(in Node importedNode, in boolean deep) raises(DOMException); // Introduced in DOM Level 2: Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); // Introduced in DOM Level 2: Attr createAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); // Introduced in DOM Level 2: NodeList getElementsByTagNameNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: Element getElementById(in DOMString elementId); }; }; #endif // _DOM_IDL_
// File: html.idl #ifndef _HTML_IDL_ #define _HTML_IDL_ #include "dom.idl" #pragma prefix "dom.w3c.org" module html { typedef dom::DOMString DOMString; typedef dom::Node Node; typedef dom::DOMImplementation DOMImplementation; typedef dom::Document Document; typedef dom::NodeList NodeList; typedef dom::Element Element; interface HTMLDocument; interface HTMLElement; interface HTMLFormElement; interface HTMLTableCaptionElement; interface HTMLTableSectionElement; interface HTMLCollection { readonly attribute unsigned long length; Node item(in unsigned long index); Node namedItem(in DOMString name); }; // Introduced in DOM Level 2: interface HTMLDOMImplementation : DOMImplementation { HTMLDocument createHTMLDocument(in DOMString title); }; interface HTMLDocument : Document { attribute DOMString title; readonly attribute DOMString referrer; readonly attribute DOMString domain; readonly attribute DOMString URL; attribute HTMLElement body; readonly attribute HTMLCollection images; readonly attribute HTMLCollection applets; readonly attribute HTMLCollection links; readonly attribute HTMLCollection forms; readonly attribute HTMLCollection anchors; attribute DOMString cookie; void open(); void close(); void write(in DOMString text); void writeln(in DOMString text); NodeList getElementsByName(in DOMString elementName); }; interface HTMLElement : Element { attribute DOMString id; attribute DOMString title; attribute DOMString lang; attribute DOMString dir; attribute DOMString className; }; interface HTMLHtmlElement : HTMLElement { attribute DOMString version; }; interface HTMLHeadElement : HTMLElement { attribute DOMString profile; }; interface HTMLLinkElement : HTMLElement { attribute boolean disabled; attribute DOMString charset; attribute DOMString href; attribute DOMString hreflang; attribute DOMString media; attribute DOMString rel; attribute DOMString rev; attribute DOMString target; attribute DOMString type; }; interface HTMLTitleElement : HTMLElement { attribute DOMString text; }; interface HTMLMetaElement : HTMLElement { attribute DOMString content; attribute DOMString httpEquiv; attribute DOMString name; attribute DOMString scheme; }; interface HTMLBaseElement : HTMLElement { attribute DOMString href; attribute DOMString target; }; interface HTMLIsIndexElement : HTMLElement { readonly attribute HTMLFormElement form; attribute DOMString prompt; }; interface HTMLStyleElement : HTMLElement { attribute boolean disabled; attribute DOMString media; attribute DOMString type; }; interface HTMLBodyElement : HTMLElement { attribute DOMString aLink; attribute DOMString background; attribute DOMString bgColor; attribute DOMString link; attribute DOMString text; attribute DOMString vLink; }; interface HTMLFormElement : HTMLElement { readonly attribute HTMLCollection elements; readonly attribute long length; attribute DOMString name; attribute DOMString acceptCharset; attribute DOMString action; attribute DOMString enctype; attribute DOMString method; attribute DOMString target; void submit(); void reset(); }; interface HTMLSelectElement : HTMLElement { readonly attribute DOMString type; attribute long selectedIndex; attribute DOMString value; readonly attribute long length; readonly attribute HTMLFormElement form; readonly attribute HTMLCollection options; attribute boolean disabled; attribute boolean multiple; attribute DOMString name; attribute long size; attribute long tabIndex; void add(in HTMLElement element, in HTMLElement before) raises(dom::DOMException); void remove(in long index); void blur(); void focus(); }; interface HTMLOptGroupElement : HTMLElement { attribute boolean disabled; attribute DOMString label; }; interface HTMLOptionElement : HTMLElement { readonly attribute HTMLFormElement form; attribute boolean defaultSelected; readonly attribute DOMString text; readonly attribute long index; attribute boolean disabled; attribute DOMString label; attribute boolean selected; attribute DOMString value; }; interface HTMLInputElement : HTMLElement { attribute DOMString defaultValue; attribute boolean defaultChecked; readonly attribute HTMLFormElement form; attribute DOMString accept; attribute DOMString accessKey; attribute DOMString align; attribute DOMString alt; attribute boolean checked; attribute boolean disabled; attribute long maxLength; attribute DOMString name; attribute boolean readOnly; attribute DOMString size; attribute DOMString src; attribute long tabIndex; readonly attribute DOMString type; attribute DOMString useMap; attribute DOMString value; void blur(); void focus(); void select(); void click(); }; interface HTMLTextAreaElement : HTMLElement { attribute DOMString defaultValue; readonly attribute HTMLFormElement form; attribute DOMString accessKey; attribute long cols; attribute boolean disabled; attribute DOMString name; attribute boolean readOnly; attribute long rows; attribute long tabIndex; readonly attribute DOMString type; attribute DOMString value; void blur(); void focus(); void select(); }; interface HTMLButtonElement : HTMLElement { readonly attribute HTMLFormElement form; attribute DOMString accessKey; attribute boolean disabled; attribute DOMString name; attribute long tabIndex; readonly attribute DOMString type; attribute DOMString value; }; interface HTMLLabelElement : HTMLElement { readonly attribute HTMLFormElement form; attribute DOMString accessKey; attribute DOMString htmlFor; }; interface HTMLFieldSetElement : HTMLElement { readonly attribute HTMLFormElement form; }; interface HTMLLegendElement : HTMLElement { readonly attribute HTMLFormElement form; attribute DOMString accessKey; attribute DOMString align; }; interface HTMLUListElement : HTMLElement { attribute boolean compact; attribute DOMString type; }; interface HTMLOListElement : HTMLElement { attribute boolean compact; attribute long start; attribute DOMString type; }; interface HTMLDListElement : HTMLElement { attribute boolean compact; }; interface HTMLDirectoryElement : HTMLElement { attribute boolean compact; }; interface HTMLMenuElement : HTMLElement { attribute boolean compact; }; interface HTMLLIElement : HTMLElement { attribute DOMString type; attribute long value; }; interface HTMLDivElement : HTMLElement { attribute DOMString align; }; interface HTMLParagraphElement : HTMLElement { attribute DOMString align; }; interface HTMLHeadingElement : HTMLElement { attribute DOMString align; }; interface HTMLQuoteElement : HTMLElement { attribute DOMString cite; }; interface HTMLPreElement : HTMLElement { attribute long width; }; interface HTMLBRElement : HTMLElement { attribute DOMString clear; }; interface HTMLBaseFontElement : HTMLElement { attribute DOMString color; attribute DOMString face; attribute DOMString size; }; interface HTMLFontElement : HTMLElement { attribute DOMString color; attribute DOMString face; attribute DOMString size; }; interface HTMLHRElement : HTMLElement { attribute DOMString align; attribute boolean noShade; attribute DOMString size; attribute DOMString width; }; interface HTMLModElement : HTMLElement { attribute DOMString cite; attribute DOMString dateTime; }; interface HTMLAnchorElement : HTMLElement { attribute DOMString accessKey; attribute DOMString charset; attribute DOMString coords; attribute DOMString href; attribute DOMString hreflang; attribute DOMString name; attribute DOMString rel; attribute DOMString rev; attribute DOMString shape; attribute long tabIndex; attribute DOMString target; attribute DOMString type; void blur(); void focus(); }; interface HTMLImageElement : HTMLElement { attribute DOMString lowSrc; attribute DOMString name; attribute DOMString align; attribute DOMString alt; attribute DOMString border; attribute DOMString height; attribute DOMString hspace; attribute boolean isMap; attribute DOMString longDesc; attribute DOMString src; attribute DOMString useMap; attribute DOMString vspace; attribute DOMString width; }; interface HTMLObjectElement : HTMLElement { readonly attribute HTMLFormElement form; attribute DOMString code; attribute DOMString align; attribute DOMString archive; attribute DOMString border; attribute DOMString codeBase; attribute DOMString codeType; attribute DOMString data; attribute boolean declare; attribute DOMString height; attribute DOMString hspace; attribute DOMString name; attribute DOMString standby; attribute long tabIndex; attribute DOMString type; attribute DOMString useMap; attribute DOMString vspace; attribute DOMString width; // Introduced in DOM Level 2: attribute Document contentDocument; }; interface HTMLParamElement : HTMLElement { attribute DOMString name; attribute DOMString type; attribute DOMString value; attribute DOMString valueType; }; interface HTMLAppletElement : HTMLElement { attribute DOMString align; attribute DOMString alt; attribute DOMString archive; attribute DOMString code; attribute DOMString codeBase; attribute DOMString height; attribute DOMString hspace; attribute DOMString name; attribute DOMString object; attribute DOMString vspace; attribute DOMString width; }; interface HTMLMapElement : HTMLElement { readonly attribute HTMLCollection areas; attribute DOMString name; }; interface HTMLAreaElement : HTMLElement { attribute DOMString accessKey; attribute DOMString alt; attribute DOMString coords; attribute DOMString href; attribute boolean noHref; attribute DOMString shape; attribute long tabIndex; attribute DOMString target; }; interface HTMLScriptElement : HTMLElement { attribute DOMString text; attribute DOMString htmlFor; attribute DOMString event; attribute DOMString charset; attribute boolean defer; attribute DOMString src; attribute DOMString type; }; interface HTMLTableElement : HTMLElement { attribute HTMLTableCaptionElement caption; attribute HTMLTableSectionElement tHead; attribute HTMLTableSectionElement tFoot; readonly attribute HTMLCollection rows; readonly attribute HTMLCollection tBodies; attribute DOMString align; attribute DOMString bgColor; attribute DOMString border; attribute DOMString cellPadding; attribute DOMString cellSpacing; attribute DOMString frame; attribute DOMString rules; attribute DOMString summary; attribute DOMString width; HTMLElement createTHead(); void deleteTHead(); HTMLElement createTFoot(); void deleteTFoot(); HTMLElement createCaption(); void deleteCaption(); HTMLElement insertRow(in long index) raises(dom::DOMException); void deleteRow(in long index) raises(dom::DOMException); }; interface HTMLTableCaptionElement : HTMLElement { attribute DOMString align; }; interface HTMLTableColElement : HTMLElement { attribute DOMString align; attribute DOMString ch; attribute DOMString chOff; attribute long span; attribute DOMString vAlign; attribute DOMString width; }; interface HTMLTableSectionElement : HTMLElement { attribute DOMString align; attribute DOMString ch; attribute DOMString chOff; attribute DOMString vAlign; readonly attribute HTMLCollection rows; HTMLElement insertRow(in long index) raises(dom::DOMException); void deleteRow(in long index) raises(dom::DOMException); }; interface HTMLTableRowElement : HTMLElement { readonly attribute long rowIndex; readonly attribute long sectionRowIndex; readonly attribute HTMLCollection cells; attribute DOMString align; attribute DOMString bgColor; attribute DOMString ch; attribute DOMString chOff; attribute DOMString vAlign; HTMLElement insertCell(in long index) raises(dom::DOMException); void deleteCell(in long index) raises(dom::DOMException); }; interface HTMLTableCellElement : HTMLElement { readonly attribute long cellIndex; attribute DOMString abbr; attribute DOMString align; attribute DOMString axis; attribute DOMString bgColor; attribute DOMString ch; attribute DOMString chOff; attribute long colSpan; attribute DOMString headers; attribute DOMString height; attribute boolean noWrap; attribute long rowSpan; attribute DOMString scope; attribute DOMString vAlign; attribute DOMString width; }; interface HTMLFrameSetElement : HTMLElement { attribute DOMString cols; attribute DOMString rows; }; interface HTMLFrameElement : HTMLElement { attribute DOMString frameBorder; attribute DOMString longDesc; attribute DOMString marginHeight; attribute DOMString marginWidth; attribute DOMString name; attribute boolean noResize; attribute DOMString scrolling; attribute DOMString src; // Introduced in DOM Level 2: attribute Document contentDocument; }; interface HTMLIFrameElement : HTMLElement { attribute DOMString align; attribute DOMString frameBorder; attribute DOMString height; attribute DOMString longDesc; attribute DOMString marginHeight; attribute DOMString marginWidth; attribute DOMString name; attribute DOMString scrolling; attribute DOMString src; attribute DOMString width; // Introduced in DOM Level 2: attribute Document contentDocument; }; }; #endif // _HTML_IDL_
// File: views.idl #ifndef _VIEWS_IDL_ #define _VIEWS_IDL_ #include "dom.idl" #pragma prefix "dom.w3c.org" module views { interface DocumentView; // Introduced in DOM Level 2: interface AbstractView { readonly attribute DocumentView document; }; // Introduced in DOM Level 2: interface DocumentView { readonly attribute AbstractView defaultView; }; }; #endif // _VIEWS_IDL_
// File: stylesheets.idl #ifndef _STYLESHEETS_IDL_ #define _STYLESHEETS_IDL_ #include "dom.idl" #include "html.idl" #pragma prefix "dom.w3c.org" module stylesheets { typedef dom::DOMString DOMString; typedef dom::Node Node; interface MediaList; // Introduced in DOM Level 2: interface StyleSheet { readonly attribute DOMString type; attribute boolean disabled; readonly attribute Node ownerNode; readonly attribute StyleSheet parentStyleSheet; readonly attribute DOMString href; readonly attribute DOMString title; readonly attribute MediaList media; }; // Introduced in DOM Level 2: interface StyleSheetList { readonly attribute unsigned long length; StyleSheet item(in unsigned long index); }; // Introduced in DOM Level 2: interface MediaList { attribute DOMString mediaText; // raises(dom::DOMException) on setting readonly attribute unsigned long length; DOMString item(in unsigned long index); void delete(in DOMString oldMedium) raises(dom::DOMException); void append(in DOMString newMedium) raises(dom::DOMException); }; // Introduced in DOM Level 2: interface LinkStyle { readonly attribute StyleSheet sheet; }; // Introduced in DOM Level 2: interface DocumentStyle { readonly attribute StyleSheetList styleSheets; }; }; #endif // _STYLESHEETS_IDL_
// File: css.idl #ifndef _CSS_IDL_ #define _CSS_IDL_ #include "dom.idl" #include "stylesheets.idl" #include "html.idl" #include "views.idl" #pragma prefix "dom.w3c.org" module css { typedef dom::DOMString DOMString; typedef dom::Element Element; typedef dom::DOMImplementation DOMImplementation; interface CSSRule; interface CSSStyleSheet; interface CSSStyleDeclaration; interface CSSValue; interface Counter; interface Rect; interface RGBColor; // Introduced in DOM Level 2: interface CSSRuleList { readonly attribute unsigned long length; CSSRule item(in unsigned long index); }; // Introduced in DOM Level 2: interface CSSRule { // RuleType const unsigned short UNKNOWN_RULE = 0; const unsigned short STYLE_RULE = 1; const unsigned short CHARSET_RULE = 2; const unsigned short IMPORT_RULE = 3; const unsigned short MEDIA_RULE = 4; const unsigned short FONT_FACE_RULE = 5; const unsigned short PAGE_RULE = 6; readonly attribute unsigned short type; attribute DOMString cssText; // raises(dom::DOMException) on setting readonly attribute CSSStyleSheet parentStyleSheet; readonly attribute CSSRule parentRule; }; // Introduced in DOM Level 2: interface CSSStyleRule : CSSRule { attribute DOMString selectorText; // raises(dom::DOMException) on setting readonly attribute CSSStyleDeclaration style; }; // Introduced in DOM Level 2: interface CSSMediaRule : CSSRule { readonly attribute stylesheets::MediaList media; readonly attribute CSSRuleList cssRules; unsigned long insertRule(in DOMString rule, in unsigned long index) raises(dom::DOMException); void deleteRule(in unsigned long index) raises(dom::DOMException); }; // Introduced in DOM Level 2: interface CSSFontFaceRule : CSSRule { readonly attribute CSSStyleDeclaration style; }; // Introduced in DOM Level 2: interface CSSPageRule : CSSRule { attribute DOMString selectorText; // raises(dom::DOMException) on setting readonly attribute CSSStyleDeclaration style; }; // Introduced in DOM Level 2: interface CSSImportRule : CSSRule { readonly attribute DOMString href; readonly attribute stylesheets::MediaList media; readonly attribute CSSStyleSheet styleSheet; }; // Introduced in DOM Level 2: interface CSSCharsetRule : CSSRule { attribute DOMString encoding; // raises(dom::DOMException) on setting }; // Introduced in DOM Level 2: interface CSSUnknownRule : CSSRule { }; // Introduced in DOM Level 2: interface CSSStyleDeclaration { attribute DOMString cssText; // raises(dom::DOMException) on setting DOMString getPropertyValue(in DOMString propertyName); CSSValue getPropertyCSSValue(in DOMString propertyName); DOMString removeProperty(in DOMString propertyName) raises(dom::DOMException); DOMString getPropertyPriority(in DOMString propertyName); void setProperty(in DOMString propertyName, in DOMString value, in DOMString priority) raises(dom::DOMException); readonly attribute unsigned long length; DOMString item(in unsigned long index); readonly attribute CSSRule parentRule; }; // Introduced in DOM Level 2: interface CSSValue { // UnitTypes const unsigned short CSS_INHERIT = 0; const unsigned short CSS_PRIMITIVE_VALUE = 1; const unsigned short CSS_VALUE_LIST = 2; const unsigned short CSS_CUSTOM = 3; attribute DOMString cssText; // raises(dom::DOMException) on setting readonly attribute unsigned short valueType; }; // Introduced in DOM Level 2: interface CSSPrimitiveValue : CSSValue { // UnitTypes const unsigned short CSS_UNKNOWN = 0; const unsigned short CSS_NUMBER = 1; const unsigned short CSS_PERCENTAGE = 2; const unsigned short CSS_EMS = 3; const unsigned short CSS_EXS = 4; const unsigned short CSS_PX = 5; const unsigned short CSS_CM = 6; const unsigned short CSS_MM = 7; const unsigned short CSS_IN = 8; const unsigned short CSS_PT = 9; const unsigned short CSS_PC = 10; const unsigned short CSS_DEG = 11; const unsigned short CSS_RAD = 12; const unsigned short CSS_GRAD = 13; const unsigned short CSS_MS = 14; const unsigned short CSS_S = 15; const unsigned short CSS_HZ = 16; const unsigned short CSS_KHZ = 17; const unsigned short CSS_DIMENSION = 18; const unsigned short CSS_STRING = 19; const unsigned short CSS_URI = 20; const unsigned short CSS_IDENT = 21; const unsigned short CSS_ATTR = 22; const unsigned short CSS_COUNTER = 23; const unsigned short CSS_RECT = 24; const unsigned short CSS_RGBCOLOR = 25; readonly attribute unsigned short primitiveType; void setFloatValue(in unsigned short unitType, in float floatValue) raises(dom::DOMException); float getFloatValue(in unsigned short unitType) raises(dom::DOMException); void setStringValue(in unsigned short stringType, in DOMString stringValue) raises(dom::DOMException); DOMString getStringValue() raises(dom::DOMException); Counter getCounterValue() raises(dom::DOMException); Rect getRectValue() raises(dom::DOMException); RGBColor getRGBColorValue() raises(dom::DOMException); }; // Introduced in DOM Level 2: interface CSSValueList : CSSValue { readonly attribute unsigned long length; CSSValue item(in unsigned long index); }; // Introduced in DOM Level 2: interface RGBColor { readonly attribute CSSPrimitiveValue red; readonly attribute CSSPrimitiveValue green; readonly attribute CSSPrimitiveValue blue; }; // Introduced in DOM Level 2: interface Rect { readonly attribute CSSPrimitiveValue top; readonly attribute CSSPrimitiveValue right; readonly attribute CSSPrimitiveValue bottom; readonly attribute CSSPrimitiveValue left; }; // Introduced in DOM Level 2: interface Counter { readonly attribute DOMString identifier; readonly attribute DOMString listStyle; readonly attribute DOMString separator; }; // Introduced in DOM Level 2: interface ElementCSSInlineStyle { readonly attribute CSSStyleDeclaration style; }; // Introduced in DOM Level 2: interface CSS2Azimuth : CSSValue { readonly attribute unsigned short azimuthType; readonly attribute DOMString identifier; readonly attribute boolean behind; void setAngleValue(in unsigned short uType, in float fValue) raises(dom::DOMException); float getAngleValue(in unsigned short uType) raises(dom::DOMException); void setIdentifier(in DOMString ident, in boolean b) raises(dom::DOMException); }; // Introduced in DOM Level 2: interface CSS2BackgroundPosition : CSSValue { readonly attribute unsigned short horizontalType; readonly attribute unsigned short verticalType; readonly attribute DOMString horizontalIdentifier; readonly attribute DOMString verticalIdentifier; float getHorizontalPosition(in float hType) raises(dom::DOMException); float getVerticalPosition(in float vType) raises(dom::DOMException); void setHorizontalPosition(in unsigned short hType, in float value) raises(dom::DOMException); void setVerticalPosition(in unsigned short vType, in float value) raises(dom::DOMException); void setPositionIdentifier(in DOMString hIdentifier, in DOMString vIdentifier) raises(dom::DOMException); }; // Introduced in DOM Level 2: interface CSS2BorderSpacing : CSSValue { readonly attribute unsigned short horizontalType; readonly attribute unsigned short verticalType; float getHorizontalSpacing(in float hType) raises(dom::DOMException); float getVerticalSpacing(in float vType) raises(dom::DOMException); void setHorizontalSpacing(in unsigned short hType, in float value) raises(dom::DOMException); void setVerticalSpacing(in unsigned short vType, in float value) raises(dom::DOMException); }; // Introduced in DOM Level 2: interface CSS2CounterReset : CSSValue { attribute DOMString identifier; // raises(dom::DOMException) on setting attribute short reset; // raises(dom::DOMException) on setting }; // Introduced in DOM Level 2: interface CSS2CounterIncrement : CSSValue { attribute DOMString identifier; // raises(dom::DOMException) on setting attribute short increment; // raises(dom::DOMException) on setting }; // Introduced in DOM Level 2: interface CSS2Cursor : CSSValue { readonly attribute CSSValueList uris; attribute DOMString predefinedCursor; // raises(dom::DOMException) on setting }; // Introduced in DOM Level 2: interface CSS2PlayDuring : CSSValue { readonly attribute unsigned short playDuringType; attribute DOMString playDuringIdentifier; // raises(dom::DOMException) on setting attribute DOMString uri; // raises(dom::DOMException) on setting attribute boolean mix; // raises(dom::DOMException) on setting attribute boolean repeat; // raises(dom::DOMException) on setting }; // Introduced in DOM Level 2: interface CSS2TextShadow { readonly attribute CSSValue color; readonly attribute CSSValue horizontal; readonly attribute CSSValue vertical; readonly attribute CSSValue blur; }; // Introduced in DOM Level 2: interface CSS2FontFaceSrc { attribute DOMString uri; // raises(dom::DOMException) on setting readonly attribute CSSValueList format; attribute DOMString fontFaceName; // raises(dom::DOMException) on setting }; // Introduced in DOM Level 2: interface CSS2FontFaceWidths { attribute DOMString urange; // raises(dom::DOMException) on setting readonly attribute CSSValueList numbers; }; // Introduced in DOM Level 2: interface CSS2PageSize : CSSValue { readonly attribute unsigned short widthType; readonly attribute unsigned short heightType; readonly attribute DOMString identifier; float getWidth(in float wType) raises(dom::DOMException); float getHeightSize(in float hType) raises(dom::DOMException); void setWidthSize(in unsigned short wType, in float value) raises(dom::DOMException); void setHeightSize(in unsigned short hType, in float value) raises(dom::DOMException); void setIdentifier(in DOMString ident) raises(dom::DOMException); }; // Introduced in DOM Level 2: interface CSS2Properties { attribute DOMString azimuth; // raises(dom::DOMException) on setting attribute DOMString background; // raises(dom::DOMException) on setting attribute DOMString backgroundAttachment; // raises(dom::DOMException) on setting attribute DOMString backgroundColor; // raises(dom::DOMException) on setting attribute DOMString backgroundImage; // raises(dom::DOMException) on setting attribute DOMString backgroundPosition; // raises(dom::DOMException) on setting attribute DOMString backgroundRepeat; // raises(dom::DOMException) on setting attribute DOMString border; // raises(dom::DOMException) on setting attribute DOMString borderCollapse; // raises(dom::DOMException) on setting attribute DOMString borderColor; // raises(dom::DOMException) on setting attribute DOMString borderSpacing; // raises(dom::DOMException) on setting attribute DOMString borderStyle; // raises(dom::DOMException) on setting attribute DOMString borderTop; // raises(dom::DOMException) on setting attribute DOMString borderRight; // raises(dom::DOMException) on setting attribute DOMString borderBottom; // raises(dom::DOMException) on setting attribute DOMString borderLeft; // raises(dom::DOMException) on setting attribute DOMString borderTopColor; // raises(dom::DOMException) on setting attribute DOMString borderRightColor; // raises(dom::DOMException) on setting attribute DOMString borderBottomColor; // raises(dom::DOMException) on setting attribute DOMString borderLeftColor; // raises(dom::DOMException) on setting attribute DOMString borderTopStyle; // raises(dom::DOMException) on setting attribute DOMString borderRightStyle; // raises(dom::DOMException) on setting attribute DOMString borderBottomStyle; // raises(dom::DOMException) on setting attribute DOMString borderLeftStyle; // raises(dom::DOMException) on setting attribute DOMString borderTopWidth; // raises(dom::DOMException) on setting attribute DOMString borderRightWidth; // raises(dom::DOMException) on setting attribute DOMString borderBottomWidth; // raises(dom::DOMException) on setting attribute DOMString borderLeftWidth; // raises(dom::DOMException) on setting attribute DOMString borderWidth; // raises(dom::DOMException) on setting attribute DOMString bottom; // raises(dom::DOMException) on setting attribute DOMString captionSide; // raises(dom::DOMException) on setting attribute DOMString clear; // raises(dom::DOMException) on setting attribute DOMString clip; // raises(dom::DOMException) on setting attribute DOMString color; // raises(dom::DOMException) on setting attribute DOMString content; // raises(dom::DOMException) on setting attribute DOMString counterIncrement; // raises(dom::DOMException) on setting attribute DOMString counterReset; // raises(dom::DOMException) on setting attribute DOMString cue; // raises(dom::DOMException) on setting attribute DOMString cueAfter; // raises(dom::DOMException) on setting attribute DOMString cueBefore; // raises(dom::DOMException) on setting attribute DOMString cursor; // raises(dom::DOMException) on setting attribute DOMString direction; // raises(dom::DOMException) on setting attribute DOMString display; // raises(dom::DOMException) on setting attribute DOMString elevation; // raises(dom::DOMException) on setting attribute DOMString emptyCells; // raises(dom::DOMException) on setting attribute DOMString cssFloat; // raises(dom::DOMException) on setting attribute DOMString font; // raises(dom::DOMException) on setting attribute DOMString fontFamily; // raises(dom::DOMException) on setting attribute DOMString fontSize; // raises(dom::DOMException) on setting attribute DOMString fontSizeAdjust; // raises(dom::DOMException) on setting attribute DOMString fontStretch; // raises(dom::DOMException) on setting attribute DOMString fontStyle; // raises(dom::DOMException) on setting attribute DOMString fontVariant; // raises(dom::DOMException) on setting attribute DOMString fontWeight; // raises(dom::DOMException) on setting attribute DOMString height; // raises(dom::DOMException) on setting attribute DOMString left; // raises(dom::DOMException) on setting attribute DOMString letterSpacing; // raises(dom::DOMException) on setting attribute DOMString lineHeight; // raises(dom::DOMException) on setting attribute DOMString listStyle; // raises(dom::DOMException) on setting attribute DOMString listStyleImage; // raises(dom::DOMException) on setting attribute DOMString listStylePosition; // raises(dom::DOMException) on setting attribute DOMString listStyleType; // raises(dom::DOMException) on setting attribute DOMString margin; // raises(dom::DOMException) on setting attribute DOMString marginTop; // raises(dom::DOMException) on setting attribute DOMString marginRight; // raises(dom::DOMException) on setting attribute DOMString marginBottom; // raises(dom::DOMException) on setting attribute DOMString marginLeft; // raises(dom::DOMException) on setting attribute DOMString markerOffset; // raises(dom::DOMException) on setting attribute DOMString marks; // raises(dom::DOMException) on setting attribute DOMString maxHeight; // raises(dom::DOMException) on setting attribute DOMString maxWidth; // raises(dom::DOMException) on setting attribute DOMString minHeight; // raises(dom::DOMException) on setting attribute DOMString minWidth; // raises(dom::DOMException) on setting attribute DOMString orphans; // raises(dom::DOMException) on setting attribute DOMString outline; // raises(dom::DOMException) on setting attribute DOMString outlineColor; // raises(dom::DOMException) on setting attribute DOMString outlineStyle; // raises(dom::DOMException) on setting attribute DOMString outlineWidth; // raises(dom::DOMException) on setting attribute DOMString overflow; // raises(dom::DOMException) on setting attribute DOMString padding; // raises(dom::DOMException) on setting attribute DOMString paddingTop; // raises(dom::DOMException) on setting attribute DOMString paddingRight; // raises(dom::DOMException) on setting attribute DOMString paddingBottom; // raises(dom::DOMException) on setting attribute DOMString paddingLeft; // raises(dom::DOMException) on setting attribute DOMString page; // raises(dom::DOMException) on setting attribute DOMString pageBreakAfter; // raises(dom::DOMException) on setting attribute DOMString pageBreakBefore; // raises(dom::DOMException) on setting attribute DOMString pageBreakInside; // raises(dom::DOMException) on setting attribute DOMString pause; // raises(dom::DOMException) on setting attribute DOMString pauseAfter; // raises(dom::DOMException) on setting attribute DOMString pauseBefore; // raises(dom::DOMException) on setting attribute DOMString pitch; // raises(dom::DOMException) on setting attribute DOMString pitchRange; // raises(dom::DOMException) on setting attribute DOMString playDuring; // raises(dom::DOMException) on setting attribute DOMString position; // raises(dom::DOMException) on setting attribute DOMString quotes; // raises(dom::DOMException) on setting attribute DOMString richness; // raises(dom::DOMException) on setting attribute DOMString right; // raises(dom::DOMException) on setting attribute DOMString size; // raises(dom::DOMException) on setting attribute DOMString speak; // raises(dom::DOMException) on setting attribute DOMString speakHeader; // raises(dom::DOMException) on setting attribute DOMString speakNumeral; // raises(dom::DOMException) on setting attribute DOMString speakPunctuation; // raises(dom::DOMException) on setting attribute DOMString speechRate; // raises(dom::DOMException) on setting attribute DOMString stress; // raises(dom::DOMException) on setting attribute DOMString tableLayout; // raises(dom::DOMException) on setting attribute DOMString textAlign; // raises(dom::DOMException) on setting attribute DOMString textDecoration; // raises(dom::DOMException) on setting attribute DOMString textIndent; // raises(dom::DOMException) on setting attribute DOMString textShadow; // raises(dom::DOMException) on setting attribute DOMString textTransform; // raises(dom::DOMException) on setting attribute DOMString top; // raises(dom::DOMException) on setting attribute DOMString unicodeBidi; // raises(dom::DOMException) on setting attribute DOMString verticalAlign; // raises(dom::DOMException) on setting attribute DOMString visibility; // raises(dom::DOMException) on setting attribute DOMString voiceFamily; // raises(dom::DOMException) on setting attribute DOMString volume; // raises(dom::DOMException) on setting attribute DOMString whiteSpace; // raises(dom::DOMException) on setting attribute DOMString widows; // raises(dom::DOMException) on setting attribute DOMString width; // raises(dom::DOMException) on setting attribute DOMString wordSpacing; // raises(dom::DOMException) on setting attribute DOMString zIndex; // raises(dom::DOMException) on setting }; // Introduced in DOM Level 2: interface CSSStyleSheet : stylesheets::StyleSheet { readonly attribute CSSRule ownerRule; readonly attribute CSSRuleList cssRules; unsigned long insertRule(in DOMString rule, in unsigned long index) raises(dom::DOMException); void deleteRule(in unsigned long index) raises(dom::DOMException); }; // Introduced in DOM Level 2: interface ViewCSS : views::AbstractView { CSSStyleDeclaration getComputedStyle(in Element elt, in DOMString pseudoElt); }; // Introduced in DOM Level 2: interface DocumentCSS : stylesheets::DocumentStyle { CSSStyleDeclaration getOverrideStyle(in Element elt, in DOMString pseudoElt); }; // Introduced in DOM Level 2: interface DOMImplementationCSS : DOMImplementation { CSSStyleSheet createCSSStyleSheet(in DOMString title, in DOMString media); }; }; #endif // _CSS_IDL_
// File: events.idl #ifndef _EVENTS_IDL_ #define _EVENTS_IDL_ #include "dom.idl" #include "views.idl" #pragma prefix "dom.w3c.org" module events { typedef dom::DOMString DOMString; typedef dom::Node Node; typedef dom::DOMTimeStamp DOMTimeStamp; interface EventListener; interface Event; // Introduced in DOM Level 2: exception EventException { unsigned short code; }; // EventExceptionCode const unsigned short UNSPECIFIED_EVENT_TYPE_ERR = 0; // Introduced in DOM Level 2: interface EventTarget { void addEventListener(in DOMString type, in EventListener listener, in boolean useCapture); void removeEventListener(in DOMString type, in EventListener listener, in boolean useCapture); boolean dispatchEvent(in Event evt) raises(EventException); }; // Introduced in DOM Level 2: interface EventListener { void handleEvent(in Event evt); }; // Introduced in DOM Level 2: interface Event { // PhaseType const unsigned short CAPTURING_PHASE = 1; const unsigned short AT_TARGET = 2; const unsigned short BUBBLING_PHASE = 3; readonly attribute DOMString type; readonly attribute EventTarget target; readonly attribute Node currentNode; readonly attribute unsigned short eventPhase; readonly attribute boolean bubbles; readonly attribute boolean cancelable; readonly attribute DOMTimeStamp timeStamp; void stopPropagation(); void preventDefault(); void initEvent(in DOMString eventTypeArg, in boolean canBubbleArg, in boolean cancelableArg); }; // Introduced in DOM Level 2: interface DocumentEvent { Event createEvent(in DOMString eventType) raises(dom::DOMException); }; // Introduced in DOM Level 2: interface UIEvent : Event { readonly attribute views::AbstractView view; readonly attribute long detail; void initUIEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in views::AbstractView viewArg, in long detailArg); }; // Introduced in DOM Level 2: interface MouseEvent : UIEvent { readonly attribute long screenX; readonly attribute long screenY; readonly attribute long clientX; readonly attribute long clientY; readonly attribute boolean ctrlKey; readonly attribute boolean shiftKey; readonly attribute boolean altKey; readonly attribute boolean metaKey; readonly attribute unsigned short button; readonly attribute Node relatedNode; void initMouseEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in views::AbstractView viewArg, in long detailArg, in long screenXArg, in long screenYArg, in long clientXArg, in long clientYArg, in boolean ctrlKeyArg, in boolean altKeyArg, in boolean shiftKeyArg, in boolean metaKeyArg, in unsigned short buttonArg, in Node relatedNodeArg); }; // Introduced in DOM Level 2: interface MutationEvent : Event { readonly attribute Node relatedNode; readonly attribute DOMString prevValue; readonly attribute DOMString newValue; readonly attribute DOMString attrName; void initMutationEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in Node relatedNodeArg, in DOMString prevValueArg, in DOMString newValueArg, in DOMString attrNameArg); }; }; #endif // _EVENTS_IDL_
// File: traversal.idl #ifndef _TRAVERSAL_IDL_ #define _TRAVERSAL_IDL_ #include "dom.idl" #pragma prefix "dom.w3c.org" module traversal { typedef dom::Node Node; interface NodeFilter; // Introduced in DOM Level 2: interface NodeIterator { readonly attribute Node root; readonly attribute unsigned long whatToShow; readonly attribute NodeFilter filter; readonly attribute boolean expandEntityReferences; Node nextNode() raises(dom::DOMException); Node previousNode() raises(dom::DOMException); void detach(); }; // Introduced in DOM Level 2: interface NodeFilter { // Constants returned by acceptNode const short FILTER_ACCEPT = 1; const short FILTER_REJECT = 2; const short FILTER_SKIP = 3; // Constants for whatToShow const unsigned long SHOW_ALL = 0xFFFFFFFF; const unsigned long SHOW_ELEMENT = 0x00000001; const unsigned long SHOW_ATTRIBUTE = 0x00000002; const unsigned long SHOW_TEXT = 0x00000004; const unsigned long SHOW_CDATA_SECTION = 0x00000008; const unsigned long SHOW_ENTITY_REFERENCE = 0x00000010; const unsigned long SHOW_ENTITY = 0x00000020; const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x00000040; const unsigned long SHOW_COMMENT = 0x00000080; const unsigned long SHOW_DOCUMENT = 0x00000100; const unsigned long SHOW_DOCUMENT_TYPE = 0x00000200; const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x00000400; const unsigned long SHOW_NOTATION = 0x00000800; short acceptNode(in Node n); }; // Introduced in DOM Level 2: interface TreeWalker { readonly attribute Node root; readonly attribute unsigned long whatToShow; readonly attribute NodeFilter filter; readonly attribute boolean expandEntityReferences; attribute Node currentNode; // raises(dom::DOMException) on setting Node parentNode(); Node firstChild(); Node lastChild(); Node previousSibling(); Node nextSibling(); Node previousNode(); Node nextNode(); }; // Introduced in DOM Level 2: interface DocumentTraversal { NodeIterator createNodeIterator(in Node root, in unsigned long whatToShow, in NodeFilter filter, in boolean entityReferenceExpansion); TreeWalker createTreeWalker(in Node root, in unsigned long whatToShow, in NodeFilter filter, in boolean entityReferenceExpansion) raises(dom::DOMException); }; }; #endif // _TRAVERSAL_IDL_
// File: range.idl #ifndef _RANGE_IDL_ #define _RANGE_IDL_ #include "dom.idl" #pragma prefix "dom.w3c.org" module range { typedef dom::Node Node; typedef dom::DocumentFragment DocumentFragment; typedef dom::DOMString DOMString; // Introduced in DOM Level 2: exception RangeException { unsigned short code; }; // RangeExceptionCode const unsigned short BAD_BOUNDARYPOINTS_ERR = 1; const unsigned short INVALID_NODE_TYPE_ERR = 2; // Introduced in DOM Level 2: interface Range { readonly attribute Node startContainer; // raises(dom::DOMException) on retrieval readonly attribute long startOffset; // raises(dom::DOMException) on retrieval readonly attribute Node endContainer; // raises(dom::DOMException) on retrieval readonly attribute long endOffset; // raises(dom::DOMException) on retrieval readonly attribute boolean collapsed; // raises(dom::DOMException) on retrieval readonly attribute Node commonAncestorContainer; // raises(dom::DOMException) on retrieval void setStart(in Node refNode, in long offset) raises(RangeException, dom::DOMException); void setEnd(in Node refNode, in long offset) raises(RangeException, dom::DOMException); void setStartBefore(in Node refNode) raises(RangeException, dom::DOMException); void setStartAfter(in Node refNode) raises(RangeException, dom::DOMException); void setEndBefore(in Node refNode) raises(RangeException, dom::DOMException); void setEndAfter(in Node refNode) raises(RangeException, dom::DOMException); void collapse(in boolean toStart) raises(dom::DOMException); void selectNode(in Node refNode) raises(RangeException, dom::DOMException); void selectNodeContents(in Node refNode) raises(RangeException, dom::DOMException); // CompareHow const unsigned short START_TO_START = 0; const unsigned short START_TO_END = 1; const unsigned short END_TO_END = 2; const unsigned short END_TO_START = 3; short compareBoundaryPoints(in unsigned short how, in Range sourceRange) raises(dom::DOMException); void deleteContents() raises(dom::DOMException); DocumentFragment extractContents() raises(dom::DOMException); DocumentFragment cloneContents() raises(dom::DOMException); void insertNode(in Node newNode) raises(dom::DOMException, RangeException); void surroundContents(in Node newParent) raises(dom::DOMException, RangeException); Range cloneRange() raises(dom::DOMException); DOMString toString() raises(dom::DOMException); void detach() raises(dom::DOMException); }; // Introduced in DOM Level 2: interface DocumentRange { Range createRange(); }; }; #endif // _RANGE_IDL_
This appendix contains the complete Java bindings for the Level 2 Document Object Model. The definitions are divided into Core, HTML, StyleSheets, CSS, Events, Filters and Iterators, and Range.
The Java files are also available as http://www.w3.org/TR/2000/CR-DOM-Level-2-20000307/java-binding.zip
package org.w3c.dom; public class DOMException extends RuntimeException { public DOMException(short code, String message) { super(message); this.code = code; } public short code; // ExceptionCode public static final short INDEX_SIZE_ERR = 1; public static final short DOMSTRING_SIZE_ERR = 2; public static final short HIERARCHY_REQUEST_ERR = 3; public static final short WRONG_DOCUMENT_ERR = 4; public static final short INVALID_CHARACTER_ERR = 5; public static final short NO_DATA_ALLOWED_ERR = 6; public static final short NO_MODIFICATION_ALLOWED_ERR = 7; public static final short NOT_FOUND_ERR = 8; public static final short NOT_SUPPORTED_ERR = 9; public static final short INUSE_ATTRIBUTE_ERR = 10; /** * @since DOM Level 2 */ public static final short INVALID_STATE_ERR = 11; /** * @since DOM Level 2 */ public static final short SYNTAX_ERR = 12; /** * @since DOM Level 2 */ public static final short INVALID_MODIFICATION_ERR = 13; /** * @since DOM Level 2 */ public static final short NAMESPACE_ERR = 14; /** * @since DOM Level 2 */ public static final short INVALID_ACCESS_ERR = 15; }
package org.w3c.dom; public interface DOMImplementation { public boolean hasFeature(String feature, String version); public DocumentType createDocumentType(String qualifiedName, String publicId, String systemId) throws DOMException; public Document createDocument(String namespaceURI, String qualifiedName, DocumentType doctype) throws DOMException; }
package org.w3c.dom; public interface DocumentFragment extends Node { }
package org.w3c.dom; public interface Document extends Node { public DocumentType getDoctype(); public DOMImplementation getImplementation(); public Element getDocumentElement(); public Element createElement(String tagName) throws DOMException; public DocumentFragment createDocumentFragment(); public Text createTextNode(String data); public Comment createComment(String data); public CDATASection createCDATASection(String data) throws DOMException; public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException; public Attr createAttribute(String name) throws DOMException; public EntityReference createEntityReference(String name) throws DOMException; public NodeList getElementsByTagName(String tagname); public Node importNode(Node importedNode, boolean deep) throws DOMException; public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException; public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException; public NodeList getElementsByTagNameNS(String namespaceURI, String localName); public Element getElementById(String elementId); }
package org.w3c.dom; public interface Node { // NodeType public static final short ELEMENT_NODE = 1; public static final short ATTRIBUTE_NODE = 2; public static final short TEXT_NODE = 3; public static final short CDATA_SECTION_NODE = 4; public static final short ENTITY_REFERENCE_NODE = 5; public static final short ENTITY_NODE = 6; public static final short PROCESSING_INSTRUCTION_NODE = 7; public static final short COMMENT_NODE = 8; public static final short DOCUMENT_NODE = 9; public static final short DOCUMENT_TYPE_NODE = 10; public static final short DOCUMENT_FRAGMENT_NODE = 11; public static final short NOTATION_NODE = 12; public String getNodeName(); public String getNodeValue() throws DOMException; public void setNodeValue(String nodeValue) throws DOMException; public short getNodeType(); public Node getParentNode(); public NodeList getChildNodes(); public Node getFirstChild(); public Node getLastChild(); public Node getPreviousSibling(); public Node getNextSibling(); public NamedNodeMap getAttributes(); public Document getOwnerDocument(); public Node insertBefore(Node newChild, Node refChild) throws DOMException; public Node replaceChild(Node newChild, Node oldChild) throws DOMException; public Node removeChild(Node oldChild) throws DOMException; public Node appendChild(Node newChild) throws DOMException; public boolean hasChildNodes(); public Node cloneNode(boolean deep); public void normalize(); public boolean supports(String feature, String version); public String getNamespaceURI(); public String getPrefix(); public void setPrefix(String prefix) throws DOMException; public String getLocalName(); }
package org.w3c.dom; public interface NodeList { public Node item(int index); public int getLength(); }
package org.w3c.dom; public interface NamedNodeMap { public Node getNamedItem(String name); public Node setNamedItem(Node arg) throws DOMException; public Node removeNamedItem(String name) throws DOMException; public Node item(int index); public int getLength(); public Node getNamedItemNS(String namespaceURI, String localName); public Node setNamedItemNS(Node arg) throws DOMException; public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException; }
package org.w3c.dom; public interface CharacterData extends Node { public String getData() throws DOMException; public void setData(String data) throws DOMException; public int getLength(); public String substringData(int offset, int count) throws DOMException; public void appendData(String arg) throws DOMException; public void insertData(int offset, String arg) throws DOMException; public void deleteData(int offset, int count) throws DOMException; public void replaceData(int offset, int count, String arg) throws DOMException; }
package org.w3c.dom; public interface Attr extends Node { public String getName(); public boolean getSpecified(); public String getValue(); public void setValue(String value) throws DOMException; public Element getOwnerElement(); }
package org.w3c.dom; public interface Element extends Node { public String getTagName(); public String getAttribute(String name); public void setAttribute(String name, String value) throws DOMException; public void removeAttribute(String name) throws DOMException; public Attr getAttributeNode(String name); public Attr setAttributeNode(Attr newAttr) throws DOMException; public Attr removeAttributeNode(Attr oldAttr) throws DOMException; public NodeList getElementsByTagName(String name); public String getAttributeNS(String namespaceURI, String localName); public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException; public void removeAttributeNS(String namespaceURI, String localName) throws DOMException; public Attr getAttributeNodeNS(String namespaceURI, String localName); public Attr setAttributeNodeNS(Attr newAttr) throws DOMException; public NodeList getElementsByTagNameNS(String namespaceURI, String localName); public boolean hasAttribute(String name); public boolean hasAttributeNS(String namespaceURI, String localName); }
package org.w3c.dom; public interface Text extends CharacterData { public Text splitText(int offset) throws DOMException; }
package org.w3c.dom; public interface Comment extends CharacterData { }
package org.w3c.dom; public interface CDATASection extends Text { }
package org.w3c.dom; public interface DocumentType extends Node { public String getName(); public NamedNodeMap getEntities(); public NamedNodeMap getNotations(); public String getPublicId(); public String getSystemId(); public String getInternalSubset(); }
package org.w3c.dom; public interface Notation extends Node { public String getPublicId(); public String getSystemId(); }
package org.w3c.dom; public interface Entity extends Node { public String getPublicId(); public String getSystemId(); public String getNotationName(); }
package org.w3c.dom; public interface EntityReference extends Node { }
package org.w3c.dom; public interface ProcessingInstruction extends Node { public String getTarget(); public String getData(); public void setData(String data) throws DOMException; }
package org.w3c.dom.html; import org.w3c.dom.DOMImplementation; public interface HTMLDOMImplementation extends DOMImplementation { public HTMLDocument createHTMLDocument(String title); }
package org.w3c.dom.html; import org.w3c.dom.Node; public interface HTMLCollection { public int getLength(); public Node item(int index); public Node namedItem(String name); }
package org.w3c.dom.html; import org.w3c.dom.Document; import org.w3c.dom.NodeList; public interface HTMLDocument extends Document { public String getTitle(); public void setTitle(String title); public String getReferrer(); public String getDomain(); public String getURL(); public HTMLElement getBody(); public void setBody(HTMLElement body); public HTMLCollection getImages(); public HTMLCollection getApplets(); public HTMLCollection getLinks(); public HTMLCollection getForms(); public HTMLCollection getAnchors(); public String getCookie(); public void setCookie(String cookie); public void open(); public void close(); public void write(String text); public void writeln(String text); public NodeList getElementsByName(String elementName); }
package org.w3c.dom.html; import org.w3c.dom.Element; public interface HTMLElement extends Element { public String getId(); public void setId(String id); public String getTitle(); public void setTitle(String title); public String getLang(); public void setLang(String lang); public String getDir(); public void setDir(String dir); public String getClassName(); public void setClassName(String className); }
package org.w3c.dom.html; public interface HTMLHtmlElement extends HTMLElement { public String getVersion(); public void setVersion(String version); }
package org.w3c.dom.html; public interface HTMLHeadElement extends HTMLElement { public String getProfile(); public void setProfile(String profile); }
package org.w3c.dom.html; public interface HTMLLinkElement extends HTMLElement { public boolean getDisabled(); public void setDisabled(boolean disabled); public String getCharset(); public void setCharset(String charset); public String getHref(); public void setHref(String href); public String getHreflang(); public void setHreflang(String hreflang); public String getMedia(); public void setMedia(String media); public String getRel(); public void setRel(String rel); public String getRev(); public void setRev(String rev); public String getTarget(); public void setTarget(String target); public String getType(); public void setType(String type); }
package org.w3c.dom.html; public interface HTMLTitleElement extends HTMLElement { public String getText(); public void setText(String text); }
package org.w3c.dom.html; public interface HTMLMetaElement extends HTMLElement { public String getContent(); public void setContent(String content); public String getHttpEquiv(); public void setHttpEquiv(String httpEquiv); public String getName(); public void setName(String name); public String getScheme(); public void setScheme(String scheme); }
package org.w3c.dom.html; public interface HTMLBaseElement extends HTMLElement { public String getHref(); public void setHref(String href); public String getTarget(); public void setTarget(String target); }
package org.w3c.dom.html; public interface HTMLIsIndexElement extends HTMLElement { public HTMLFormElement getForm(); public String getPrompt(); public void setPrompt(String prompt); }
package org.w3c.dom.html; public interface HTMLStyleElement extends HTMLElement { public boolean getDisabled(); public void setDisabled(boolean disabled); public String getMedia(); public void setMedia(String media); public String getType(); public void setType(String type); }
package org.w3c.dom.html; public interface HTMLBodyElement extends HTMLElement { public String getALink(); public void setALink(String aLink); public String getBackground(); public void setBackground(String background); public String getBgColor(); public void setBgColor(String bgColor); public String getLink(); public void setLink(String link); public String getText(); public void setText(String text); public String getVLink(); public void setVLink(String vLink); }
package org.w3c.dom.html; public interface HTMLFormElement extends HTMLElement { public HTMLCollection getElements(); public int getLength(); public String getName(); public void setName(String name); public String getAcceptCharset(); public void setAcceptCharset(String acceptCharset); public String getAction(); public void setAction(String action); public String getEnctype(); public void setEnctype(String enctype); public String getMethod(); public void setMethod(String method); public String getTarget(); public void setTarget(String target); public void submit(); public void reset(); }
package org.w3c.dom.html; import org.w3c.dom.DOMException; public interface HTMLSelectElement extends HTMLElement { public String getType(); public int getSelectedIndex(); public void setSelectedIndex(int selectedIndex); public String getValue(); public void setValue(String value); public int getLength(); public HTMLFormElement getForm(); public HTMLCollection getOptions(); public boolean getDisabled(); public void setDisabled(boolean disabled); public boolean getMultiple(); public void setMultiple(boolean multiple); public String getName(); public void setName(String name); public int getSize(); public void setSize(int size); public int getTabIndex(); public void setTabIndex(int tabIndex); public void add(HTMLElement element, HTMLElement before) throws DOMException; public void remove(int index); public void blur(); public void focus(); }
package org.w3c.dom.html; public interface HTMLOptGroupElement extends HTMLElement { public boolean getDisabled(); public void setDisabled(boolean disabled); public String getLabel(); public void setLabel(String label); }
package org.w3c.dom.html; public interface HTMLOptionElement extends HTMLElement { public HTMLFormElement getForm(); public boolean getDefaultSelected(); public void setDefaultSelected(boolean defaultSelected); public String getText(); public int getIndex(); public boolean getDisabled(); public void setDisabled(boolean disabled); public String getLabel(); public void setLabel(String label); public boolean getSelected(); public void setSelected(boolean selected); public String getValue(); public void setValue(String value); }
package org.w3c.dom.html; public interface HTMLInputElement extends HTMLElement { public String getDefaultValue(); public void setDefaultValue(String defaultValue); public boolean getDefaultChecked(); public void setDefaultChecked(boolean defaultChecked); public HTMLFormElement getForm(); public String getAccept(); public void setAccept(String accept); public String getAccessKey(); public void setAccessKey(String accessKey); public String getAlign(); public void setAlign(String align); public String getAlt(); public void setAlt(String alt); public boolean getChecked(); public void setChecked(boolean checked); public boolean getDisabled(); public void setDisabled(boolean disabled); public int getMaxLength(); public void setMaxLength(int maxLength); public String getName(); public void setName(String name); public boolean getReadOnly(); public void setReadOnly(boolean readOnly); public String getSize(); public void setSize(String size); public String getSrc(); public void setSrc(String src); public int getTabIndex(); public void setTabIndex(int tabIndex); public String getType(); public String getUseMap(); public void setUseMap(String useMap); public String getValue(); public void setValue(String value); public void blur(); public void focus(); public void select(); public void click(); }
package org.w3c.dom.html; public interface HTMLTextAreaElement extends HTMLElement { public String getDefaultValue(); public void setDefaultValue(String defaultValue); public HTMLFormElement getForm(); public String getAccessKey(); public void setAccessKey(String accessKey); public int getCols(); public void setCols(int cols); public boolean getDisabled(); public void setDisabled(boolean disabled); public String getName(); public void setName(String name); public boolean getReadOnly(); public void setReadOnly(boolean readOnly); public int getRows(); public void setRows(int rows); public int getTabIndex(); public void setTabIndex(int tabIndex); public String getType(); public String getValue(); public void setValue(String value); public void blur(); public void focus(); public void select(); }
package org.w3c.dom.html; public interface HTMLButtonElement extends HTMLElement { public HTMLFormElement getForm(); public String getAccessKey(); public void setAccessKey(String accessKey); public boolean getDisabled(); public void setDisabled(boolean disabled); public String getName(); public void setName(String name); public int getTabIndex(); public void setTabIndex(int tabIndex); public String getType(); public String getValue(); public void setValue(String value); }
package org.w3c.dom.html; public interface HTMLLabelElement extends HTMLElement { public HTMLFormElement getForm(); public String getAccessKey(); public void setAccessKey(String accessKey); public String getHtmlFor(); public void setHtmlFor(String htmlFor); }
package org.w3c.dom.html; public interface HTMLFieldSetElement extends HTMLElement { public HTMLFormElement getForm(); }
package org.w3c.dom.html; public interface HTMLLegendElement extends HTMLElement { public HTMLFormElement getForm(); public String getAccessKey(); public void setAccessKey(String accessKey); public String getAlign(); public void setAlign(String align); }
package org.w3c.dom.html; public interface HTMLUListElement extends HTMLElement { public boolean getCompact(); public void setCompact(boolean compact); public String getType(); public void setType(String type); }
package org.w3c.dom.html; public interface HTMLOListElement extends HTMLElement { public boolean getCompact(); public void setCompact(boolean compact); public int getStart(); public void setStart(int start); public String getType(); public void setType(String type); }
package org.w3c.dom.html; public interface HTMLDListElement extends HTMLElement { public boolean getCompact(); public void setCompact(boolean compact); }
package org.w3c.dom.html; public interface HTMLDirectoryElement extends HTMLElement { public boolean getCompact(); public void setCompact(boolean compact); }
package org.w3c.dom.html; public interface HTMLMenuElement extends HTMLElement { public boolean getCompact(); public void setCompact(boolean compact); }
package org.w3c.dom.html; public interface HTMLLIElement extends HTMLElement { public String getType(); public void setType(String type); public int getValue(); public void setValue(int value); }
package org.w3c.dom.html; public interface HTMLDivElement extends HTMLElement { public String getAlign(); public void setAlign(String align); }
package org.w3c.dom.html; public interface HTMLParagraphElement extends HTMLElement { public String getAlign(); public void setAlign(String align); }
package org.w3c.dom.html; public interface HTMLHeadingElement extends HTMLElement { public String getAlign(); public void setAlign(String align); }
package org.w3c.dom.html; public interface HTMLQuoteElement extends HTMLElement { public String getCite(); public void setCite(String cite); }
package org.w3c.dom.html; public interface HTMLPreElement extends HTMLElement { public int getWidth(); public void setWidth(int width); }
package org.w3c.dom.html; public interface HTMLBRElement extends HTMLElement { public String getClear(); public void setClear(String clear); }
package org.w3c.dom.html; public interface HTMLBaseFontElement extends HTMLElement { public String getColor(); public void setColor(String color); public String getFace(); public void setFace(String face); public String getSize(); public void setSize(String size); }
package org.w3c.dom.html; public interface HTMLFontElement extends HTMLElement { public String getColor(); public void setColor(String color); public String getFace(); public void setFace(String face); public String getSize(); public void setSize(String size); }
package org.w3c.dom.html; public interface HTMLHRElement extends HTMLElement { public String getAlign(); public void setAlign(String align); public boolean getNoShade(); public void setNoShade(boolean noShade); public String getSize(); public void setSize(String size); public String getWidth(); public void setWidth(String width); }
package org.w3c.dom.html; public interface HTMLModElement extends HTMLElement { public String getCite(); public void setCite(String cite); public String getDateTime(); public void setDateTime(String dateTime); }
package org.w3c.dom.html; public interface HTMLAnchorElement extends HTMLElement { public String getAccessKey(); public void setAccessKey(String accessKey); public String getCharset(); public void setCharset(String charset); public String getCoords(); public void setCoords(String coords); public String getHref(); public void setHref(String href); public String getHreflang(); public void setHreflang(String hreflang); public String getName(); public void setName(String name); public String getRel(); public void setRel(String rel); public String getRev(); public void setRev(String rev); public String getShape(); public void setShape(String shape); public int getTabIndex(); public void setTabIndex(int tabIndex); public String getTarget(); public void setTarget(String target); public String getType(); public void setType(String type); public void blur(); public void focus(); }
package org.w3c.dom.html; public interface HTMLImageElement extends HTMLElement { public String getLowSrc(); public void setLowSrc(String lowSrc); public String getName(); public void setName(String name); public String getAlign(); public void setAlign(String align); public String getAlt(); public void setAlt(String alt); public String getBorder(); public void setBorder(String border); public String getHeight(); public void setHeight(String height); public String getHspace(); public void setHspace(String hspace); public boolean getIsMap(); public void setIsMap(boolean isMap); public String getLongDesc(); public void setLongDesc(String longDesc); public String getSrc(); public void setSrc(String src); public String getUseMap(); public void setUseMap(String useMap); public String getVspace(); public void setVspace(String vspace); public String getWidth(); public void setWidth(String width); }
package org.w3c.dom.html; import org.w3c.dom.Document; public interface HTMLObjectElement extends HTMLElement { public HTMLFormElement getForm(); public String getCode(); public void setCode(String code); public String getAlign(); public void setAlign(String align); public String getArchive(); public void setArchive(String archive); public String getBorder(); public void setBorder(String border); public String getCodeBase(); public void setCodeBase(String codeBase); public String getCodeType(); public void setCodeType(String codeType); public String getData(); public void setData(String data); public boolean getDeclare(); public void setDeclare(boolean declare); public String getHeight(); public void setHeight(String height); public String getHspace(); public void setHspace(String hspace); public String getName(); public void setName(String name); public String getStandby(); public void setStandby(String standby); public int getTabIndex(); public void setTabIndex(int tabIndex); public String getType(); public void setType(String type); public String getUseMap(); public void setUseMap(String useMap); public String getVspace(); public void setVspace(String vspace); public String getWidth(); public void setWidth(String width); public Document getContentDocument(); public void setContentDocument(Document contentDocument); }
package org.w3c.dom.html; public interface HTMLParamElement extends HTMLElement { public String getName(); public void setName(String name); public String getType(); public void setType(String type); public String getValue(); public void setValue(String value); public String getValueType(); public void setValueType(String valueType); }
package org.w3c.dom.html; public interface HTMLAppletElement extends HTMLElement { public String getAlign(); public void setAlign(String align); public String getAlt(); public void setAlt(String alt); public String getArchive(); public void setArchive(String archive); public String getCode(); public void setCode(String code); public String getCodeBase(); public void setCodeBase(String codeBase); public String getHeight(); public void setHeight(String height); public String getHspace(); public void setHspace(String hspace); public String getName(); public void setName(String name); public String getObject(); public void setObject(String object); public String getVspace(); public void setVspace(String vspace); public String getWidth(); public void setWidth(String width); }
package org.w3c.dom.html; public interface HTMLMapElement extends HTMLElement { public HTMLCollection getAreas(); public String getName(); public void setName(String name); }
package org.w3c.dom.html; public interface HTMLAreaElement extends HTMLElement { public String getAccessKey(); public void setAccessKey(String accessKey); public String getAlt(); public void setAlt(String alt); public String getCoords(); public void setCoords(String coords); public String getHref(); public void setHref(String href); public boolean getNoHref(); public void setNoHref(boolean noHref); public String getShape(); public void setShape(String shape); public int getTabIndex(); public void setTabIndex(int tabIndex); public String getTarget(); public void setTarget(String target); }
package org.w3c.dom.html; public interface HTMLScriptElement extends HTMLElement { public String getText(); public void setText(String text); public String getHtmlFor(); public void setHtmlFor(String htmlFor); public String getEvent(); public void setEvent(String event); public String getCharset(); public void setCharset(String charset); public boolean getDefer(); public void setDefer(boolean defer); public String getSrc(); public void setSrc(String src); public String getType(); public void setType(String type); }
package org.w3c.dom.html; import org.w3c.dom.DOMException; public interface HTMLTableElement extends HTMLElement { public HTMLTableCaptionElement getCaption(); public void setCaption(HTMLTableCaptionElement caption); public HTMLTableSectionElement getTHead(); public void setTHead(HTMLTableSectionElement tHead); public HTMLTableSectionElement getTFoot(); public void setTFoot(HTMLTableSectionElement tFoot); public HTMLCollection getRows(); public HTMLCollection getTBodies(); public String getAlign(); public void setAlign(String align); public String getBgColor(); public void setBgColor(String bgColor); public String getBorder(); public void setBorder(String border); public String getCellPadding(); public void setCellPadding(String cellPadding); public String getCellSpacing(); public void setCellSpacing(String cellSpacing); public String getFrame(); public void setFrame(String frame); public String getRules(); public void setRules(String rules); public String getSummary(); public void setSummary(String summary); public String getWidth(); public void setWidth(String width); public HTMLElement createTHead(); public void deleteTHead(); public HTMLElement createTFoot(); public void deleteTFoot(); public HTMLElement createCaption(); public void deleteCaption(); public HTMLElement insertRow(int index) throws DOMException; public void deleteRow(int index) throws DOMException; }
package org.w3c.dom.html; public interface HTMLTableCaptionElement extends HTMLElement { public String getAlign(); public void setAlign(String align); }
package org.w3c.dom.html; public interface HTMLTableColElement extends HTMLElement { public String getAlign(); public void setAlign(String align); public String getCh(); public void setCh(String ch); public String getChOff(); public void setChOff(String chOff); public int getSpan(); public void setSpan(int span); public String getVAlign(); public void setVAlign(String vAlign); public String getWidth(); public void setWidth(String width); }
package org.w3c.dom.html; import org.w3c.dom.DOMException; public interface HTMLTableSectionElement extends HTMLElement { public String getAlign(); public void setAlign(String align); public String getCh(); public void setCh(String ch); public String getChOff(); public void setChOff(String chOff); public String getVAlign(); public void setVAlign(String vAlign); public HTMLCollection getRows(); public HTMLElement insertRow(int index) throws DOMException; public void deleteRow(int index) throws DOMException; }
package org.w3c.dom.html; import org.w3c.dom.DOMException; public interface HTMLTableRowElement extends HTMLElement { public int getRowIndex(); public int getSectionRowIndex(); public HTMLCollection getCells(); public String getAlign(); public void setAlign(String align); public String getBgColor(); public void setBgColor(String bgColor); public String getCh(); public void setCh(String ch); public String getChOff(); public void setChOff(String chOff); public String getVAlign(); public void setVAlign(String vAlign); public HTMLElement insertCell(int index) throws DOMException; public void deleteCell(int index) throws DOMException; }
package org.w3c.dom.html; public interface HTMLTableCellElement extends HTMLElement { public int getCellIndex(); public String getAbbr(); public void setAbbr(String abbr); public String getAlign(); public void setAlign(String align); public String getAxis(); public void setAxis(String axis); public String getBgColor(); public void setBgColor(String bgColor); public String getCh(); public void setCh(String ch); public String getChOff(); public void setChOff(String chOff); public int getColSpan(); public void setColSpan(int colSpan); public String getHeaders(); public void setHeaders(String headers); public String getHeight(); public void setHeight(String height); public boolean getNoWrap(); public void setNoWrap(boolean noWrap); public int getRowSpan(); public void setRowSpan(int rowSpan); public String getScope(); public void setScope(String scope); public String getVAlign(); public void setVAlign(String vAlign); public String getWidth(); public void setWidth(String width); }
package org.w3c.dom.html; public interface HTMLFrameSetElement extends HTMLElement { public String getCols(); public void setCols(String cols); public String getRows(); public void setRows(String rows); }
package org.w3c.dom.html; import org.w3c.dom.Document; public interface HTMLFrameElement extends HTMLElement { public String getFrameBorder(); public void setFrameBorder(String frameBorder); public String getLongDesc(); public void setLongDesc(String longDesc); public String getMarginHeight(); public void setMarginHeight(String marginHeight); public String getMarginWidth(); public void setMarginWidth(String marginWidth); public String getName(); public void setName(String name); public boolean getNoResize(); public void setNoResize(boolean noResize); public String getScrolling(); public void setScrolling(String scrolling); public String getSrc(); public void setSrc(String src); public Document getContentDocument(); public void setContentDocument(Document contentDocument); }
package org.w3c.dom.html; import org.w3c.dom.Document; public interface HTMLIFrameElement extends HTMLElement { public String getAlign(); public void setAlign(String align); public String getFrameBorder(); public void setFrameBorder(String frameBorder); public String getHeight(); public void setHeight(String height); public String getLongDesc(); public void setLongDesc(String longDesc); public String getMarginHeight(); public void setMarginHeight(String marginHeight); public String getMarginWidth(); public void setMarginWidth(String marginWidth); public String getName(); public void setName(String name); public String getScrolling(); public void setScrolling(String scrolling); public String getSrc(); public void setSrc(String src); public String getWidth(); public void setWidth(String width); public Document getContentDocument(); public void setContentDocument(Document contentDocument); }
package org.w3c.dom.views; public interface AbstractView { public DocumentView getDocument(); }
package org.w3c.dom.views; public interface DocumentView { public AbstractView getDefaultView(); }
package org.w3c.dom.stylesheets; import org.w3c.dom.Node; public interface StyleSheet { public String getType(); public boolean getDisabled(); public void setDisabled(boolean disabled); public Node getOwnerNode(); public StyleSheet getParentStyleSheet(); public String getHref(); public String getTitle(); public MediaList getMedia(); }
package org.w3c.dom.stylesheets; public interface StyleSheetList { public int getLength(); public StyleSheet item(int index); }
package org.w3c.dom.stylesheets; import org.w3c.dom.DOMException; public interface MediaList { public String getMediaText(); public void setMediaText(String mediaText) throws DOMException; public int getLength(); public String item(int index); public void delete(String oldMedium) throws DOMException; public void append(String newMedium) throws DOMException; }
package org.w3c.dom.stylesheets; public interface LinkStyle { public StyleSheet getSheet(); }
package org.w3c.dom.stylesheets; public interface DocumentStyle { public StyleSheetList getStyleSheets(); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; import org.w3c.dom.stylesheets.StyleSheet; public interface CSSStyleSheet extends StyleSheet { public CSSRule getOwnerRule(); public CSSRuleList getCssRules(); public int insertRule(String rule, int index) throws DOMException; public void deleteRule(int index) throws DOMException; }
package org.w3c.dom.css; public interface CSSRuleList { public int getLength(); public CSSRule item(int index); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSSRule { // RuleType public static final short UNKNOWN_RULE = 0; public static final short STYLE_RULE = 1; public static final short CHARSET_RULE = 2; public static final short IMPORT_RULE = 3; public static final short MEDIA_RULE = 4; public static final short FONT_FACE_RULE = 5; public static final short PAGE_RULE = 6; public short getType(); public String getCssText(); public void setCssText(String cssText) throws DOMException; public CSSStyleSheet getParentStyleSheet(); public CSSRule getParentRule(); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSSStyleRule extends CSSRule { public String getSelectorText(); public void setSelectorText(String selectorText) throws DOMException; public CSSStyleDeclaration getStyle(); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; import org.w3c.dom.stylesheets.MediaList; public interface CSSMediaRule extends CSSRule { public MediaList getMedia(); public CSSRuleList getCssRules(); public int insertRule(String rule, int index) throws DOMException; public void deleteRule(int index) throws DOMException; }
package org.w3c.dom.css; public interface CSSFontFaceRule extends CSSRule { public CSSStyleDeclaration getStyle(); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSSPageRule extends CSSRule { public String getSelectorText(); public void setSelectorText(String selectorText) throws DOMException; public CSSStyleDeclaration getStyle(); }
package org.w3c.dom.css; import org.w3c.dom.stylesheets.MediaList; public interface CSSImportRule extends CSSRule { public String getHref(); public MediaList getMedia(); public CSSStyleSheet getStyleSheet(); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSSCharsetRule extends CSSRule { public String getEncoding(); public void setEncoding(String encoding) throws DOMException; }
package org.w3c.dom.css; public interface CSSUnknownRule extends CSSRule { }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSSStyleDeclaration { public String getCssText(); public void setCssText(String cssText) throws DOMException; public String getPropertyValue(String propertyName); public CSSValue getPropertyCSSValue(String propertyName); public String removeProperty(String propertyName) throws DOMException; public String getPropertyPriority(String propertyName); public void setProperty(String propertyName, String value, String priority) throws DOMException; public int getLength(); public String item(int index); public CSSRule getParentRule(); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSSValue { // UnitTypes public static final short CSS_INHERIT = 0; public static final short CSS_PRIMITIVE_VALUE = 1; public static final short CSS_VALUE_LIST = 2; public static final short CSS_CUSTOM = 3; public String getCssText(); public void setCssText(String cssText) throws DOMException; public short getValueType(); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSSPrimitiveValue extends CSSValue { // UnitTypes public static final short CSS_UNKNOWN = 0; public static final short CSS_NUMBER = 1; public static final short CSS_PERCENTAGE = 2; public static final short CSS_EMS = 3; public static final short CSS_EXS = 4; public static final short CSS_PX = 5; public static final short CSS_CM = 6; public static final short CSS_MM = 7; public static final short CSS_IN = 8; public static final short CSS_PT = 9; public static final short CSS_PC = 10; public static final short CSS_DEG = 11; public static final short CSS_RAD = 12; public static final short CSS_GRAD = 13; public static final short CSS_MS = 14; public static final short CSS_S = 15; public static final short CSS_HZ = 16; public static final short CSS_KHZ = 17; public static final short CSS_DIMENSION = 18; public static final short CSS_STRING = 19; public static final short CSS_URI = 20; public static final short CSS_IDENT = 21; public static final short CSS_ATTR = 22; public static final short CSS_COUNTER = 23; public static final short CSS_RECT = 24; public static final short CSS_RGBCOLOR = 25; public short getPrimitiveType(); public void setFloatValue(short unitType, float floatValue) throws DOMException; public float getFloatValue(short unitType) throws DOMException; public void setStringValue(short stringType, String stringValue) throws DOMException; public String getStringValue() throws DOMException; public Counter getCounterValue() throws DOMException; public Rect getRectValue() throws DOMException; public RGBColor getRGBColorValue() throws DOMException; }
package org.w3c.dom.css; public interface CSSValueList extends CSSValue { public int getLength(); public CSSValue item(int index); }
package org.w3c.dom.css; public interface RGBColor { public CSSPrimitiveValue getRed(); public CSSPrimitiveValue getGreen(); public CSSPrimitiveValue getBlue(); }
package org.w3c.dom.css; public interface Rect { public CSSPrimitiveValue getTop(); public CSSPrimitiveValue getRight(); public CSSPrimitiveValue getBottom(); public CSSPrimitiveValue getLeft(); }
package org.w3c.dom.css; public interface Counter { public String getIdentifier(); public String getListStyle(); public String getSeparator(); }
package org.w3c.dom.css; import org.w3c.dom.Element; import org.w3c.dom.views.AbstractView; public interface ViewCSS extends AbstractView { public CSSStyleDeclaration getComputedStyle(Element elt, String pseudoElt); }
package org.w3c.dom.css; import org.w3c.dom.Element; import org.w3c.dom.stylesheets.DocumentStyle; public interface DocumentCSS extends DocumentStyle { public CSSStyleDeclaration getOverrideStyle(Element elt, String pseudoElt); }
package org.w3c.dom.css; import org.w3c.dom.DOMImplementation; public interface DOMImplementationCSS extends DOMImplementation { public CSSStyleSheet createCSSStyleSheet(String title, String media); }
package org.w3c.dom.css; public interface ElementCSSInlineStyle { public CSSStyleDeclaration getStyle(); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2Azimuth extends CSSValue { public short getAzimuthType(); public String getIdentifier(); public boolean getBehind(); public void setAngleValue(short uType, float fValue) throws DOMException; public float getAngleValue(short uType) throws DOMException; public void setIdentifier(String ident, boolean b) throws DOMException; }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2BackgroundPosition extends CSSValue { public short getHorizontalType(); public short getVerticalType(); public String getHorizontalIdentifier(); public String getVerticalIdentifier(); public float getHorizontalPosition(float hType) throws DOMException; public float getVerticalPosition(float vType) throws DOMException; public void setHorizontalPosition(short hType, float value) throws DOMException; public void setVerticalPosition(short vType, float value) throws DOMException; public void setPositionIdentifier(String hIdentifier, String vIdentifier) throws DOMException; }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2BorderSpacing extends CSSValue { public short getHorizontalType(); public short getVerticalType(); public float getHorizontalSpacing(float hType) throws DOMException; public float getVerticalSpacing(float vType) throws DOMException; public void setHorizontalSpacing(short hType, float value) throws DOMException; public void setVerticalSpacing(short vType, float value) throws DOMException; }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2CounterReset extends CSSValue { public String getIdentifier(); public void setIdentifier(String identifier) throws DOMException; public short getReset(); public void setReset(short reset) throws DOMException; }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2CounterIncrement extends CSSValue { public String getIdentifier(); public void setIdentifier(String identifier) throws DOMException; public short getIncrement(); public void setIncrement(short increment) throws DOMException; }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2Cursor extends CSSValue { public CSSValueList getUris(); public String getPredefinedCursor(); public void setPredefinedCursor(String predefinedCursor) throws DOMException; }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2PlayDuring extends CSSValue { public short getPlayDuringType(); public String getPlayDuringIdentifier(); public void setPlayDuringIdentifier(String playDuringIdentifier) throws DOMException; public String getUri(); public void setUri(String uri) throws DOMException; public boolean getMix(); public void setMix(boolean mix) throws DOMException; public boolean getRepeat(); public void setRepeat(boolean repeat) throws DOMException; }
package org.w3c.dom.css; public interface CSS2TextShadow { public CSSValue getColor(); public CSSValue getHorizontal(); public CSSValue getVertical(); public CSSValue getBlur(); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2FontFaceSrc { public String getUri(); public void setUri(String uri) throws DOMException; public CSSValueList getFormat(); public String getFontFaceName(); public void setFontFaceName(String fontFaceName) throws DOMException; }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2FontFaceWidths { public String getUrange(); public void setUrange(String urange) throws DOMException; public CSSValueList getNumbers(); }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2PageSize extends CSSValue { public short getWidthType(); public short getHeightType(); public String getIdentifier(); public float getWidth(float wType) throws DOMException; public float getHeightSize(float hType) throws DOMException; public void setWidthSize(short wType, float value) throws DOMException; public void setHeightSize(short hType, float value) throws DOMException; public void setIdentifier(String ident) throws DOMException; }
package org.w3c.dom.css; import org.w3c.dom.DOMException; public interface CSS2Properties { public String getAzimuth(); public void setAzimuth(String azimuth) throws DOMException; public String getBackground(); public void setBackground(String background) throws DOMException; public String getBackgroundAttachment(); public void setBackgroundAttachment(String backgroundAttachment) throws DOMException; public String getBackgroundColor(); public void setBackgroundColor(String backgroundColor) throws DOMException; public String getBackgroundImage(); public void setBackgroundImage(String backgroundImage) throws DOMException; public String getBackgroundPosition(); public void setBackgroundPosition(String backgroundPosition) throws DOMException; public String getBackgroundRepeat(); public void setBackgroundRepeat(String backgroundRepeat) throws DOMException; public String getBorder(); public void setBorder(String border) throws DOMException; public String getBorderCollapse(); public void setBorderCollapse(String borderCollapse) throws DOMException; public String getBorderColor(); public void setBorderColor(String borderColor) throws DOMException; public String getBorderSpacing(); public void setBorderSpacing(String borderSpacing) throws DOMException; public String getBorderStyle(); public void setBorderStyle(String borderStyle) throws DOMException; public String getBorderTop(); public void setBorderTop(String borderTop) throws DOMException; public String getBorderRight(); public void setBorderRight(String borderRight) throws DOMException; public String getBorderBottom(); public void setBorderBottom(String borderBottom) throws DOMException; public String getBorderLeft(); public void setBorderLeft(String borderLeft) throws DOMException; public String getBorderTopColor(); public void setBorderTopColor(String borderTopColor) throws DOMException; public String getBorderRightColor(); public void setBorderRightColor(String borderRightColor) throws DOMException; public String getBorderBottomColor(); public void setBorderBottomColor(String borderBottomColor) throws DOMException; public String getBorderLeftColor(); public void setBorderLeftColor(String borderLeftColor) throws DOMException; public String getBorderTopStyle(); public void setBorderTopStyle(String borderTopStyle) throws DOMException; public String getBorderRightStyle(); public void setBorderRightStyle(String borderRightStyle) throws DOMException; public String getBorderBottomStyle(); public void setBorderBottomStyle(String borderBottomStyle) throws DOMException; public String getBorderLeftStyle(); public void setBorderLeftStyle(String borderLeftStyle) throws DOMException; public String getBorderTopWidth(); public void setBorderTopWidth(String borderTopWidth) throws DOMException; public String getBorderRightWidth(); public void setBorderRightWidth(String borderRightWidth) throws DOMException; public String getBorderBottomWidth(); public void setBorderBottomWidth(String borderBottomWidth) throws DOMException; public String getBorderLeftWidth(); public void setBorderLeftWidth(String borderLeftWidth) throws DOMException; public String getBorderWidth(); public void setBorderWidth(String borderWidth) throws DOMException; public String getBottom(); public void setBottom(String bottom) throws DOMException; public String getCaptionSide(); public void setCaptionSide(String captionSide) throws DOMException; public String getClear(); public void setClear(String clear) throws DOMException; public String getClip(); public void setClip(String clip) throws DOMException; public String getColor(); public void setColor(String color) throws DOMException; public String getContent(); public void setContent(String content) throws DOMException; public String getCounterIncrement(); public void setCounterIncrement(String counterIncrement) throws DOMException; public String getCounterReset(); public void setCounterReset(String counterReset) throws DOMException; public String getCue(); public void setCue(String cue) throws DOMException; public String getCueAfter(); public void setCueAfter(String cueAfter) throws DOMException; public String getCueBefore(); public void setCueBefore(String cueBefore) throws DOMException; public String getCursor(); public void setCursor(String cursor) throws DOMException; public String getDirection(); public void setDirection(String direction) throws DOMException; public String getDisplay(); public void setDisplay(String display) throws DOMException; public String getElevation(); public void setElevation(String elevation) throws DOMException; public String getEmptyCells(); public void setEmptyCells(String emptyCells) throws DOMException; public String getCssFloat(); public void setCssFloat(String cssFloat) throws DOMException; public String getFont(); public void setFont(String font) throws DOMException; public String getFontFamily(); public void setFontFamily(String fontFamily) throws DOMException; public String getFontSize(); public void setFontSize(String fontSize) throws DOMException; public String getFontSizeAdjust(); public void setFontSizeAdjust(String fontSizeAdjust) throws DOMException; public String getFontStretch(); public void setFontStretch(String fontStretch) throws DOMException; public String getFontStyle(); public void setFontStyle(String fontStyle) throws DOMException; public String getFontVariant(); public void setFontVariant(String fontVariant) throws DOMException; public String getFontWeight(); public void setFontWeight(String fontWeight) throws DOMException; public String getHeight(); public void setHeight(String height) throws DOMException; public String getLeft(); public void setLeft(String left) throws DOMException; public String getLetterSpacing(); public void setLetterSpacing(String letterSpacing) throws DOMException; public String getLineHeight(); public void setLineHeight(String lineHeight) throws DOMException; public String getListStyle(); public void setListStyle(String listStyle) throws DOMException; public String getListStyleImage(); public void setListStyleImage(String listStyleImage) throws DOMException; public String getListStylePosition(); public void setListStylePosition(String listStylePosition) throws DOMException; public String getListStyleType(); public void setListStyleType(String listStyleType) throws DOMException; public String getMargin(); public void setMargin(String margin) throws DOMException; public String getMarginTop(); public void setMarginTop(String marginTop) throws DOMException; public String getMarginRight(); public void setMarginRight(String marginRight) throws DOMException; public String getMarginBottom(); public void setMarginBottom(String marginBottom) throws DOMException; public String getMarginLeft(); public void setMarginLeft(String marginLeft) throws DOMException; public String getMarkerOffset(); public void setMarkerOffset(String markerOffset) throws DOMException; public String getMarks(); public void setMarks(String marks) throws DOMException; public String getMaxHeight(); public void setMaxHeight(String maxHeight) throws DOMException; public String getMaxWidth(); public void setMaxWidth(String maxWidth) throws DOMException; public String getMinHeight(); public void setMinHeight(String minHeight) throws DOMException; public String getMinWidth(); public void setMinWidth(String minWidth) throws DOMException; public String getOrphans(); public void setOrphans(String orphans) throws DOMException; public String getOutline(); public void setOutline(String outline) throws DOMException; public String getOutlineColor(); public void setOutlineColor(String outlineColor) throws DOMException; public String getOutlineStyle(); public void setOutlineStyle(String outlineStyle) throws DOMException; public String getOutlineWidth(); public void setOutlineWidth(String outlineWidth) throws DOMException; public String getOverflow(); public void setOverflow(String overflow) throws DOMException; public String getPadding(); public void setPadding(String padding) throws DOMException; public String getPaddingTop(); public void setPaddingTop(String paddingTop) throws DOMException; public String getPaddingRight(); public void setPaddingRight(String paddingRight) throws DOMException; public String getPaddingBottom(); public void setPaddingBottom(String paddingBottom) throws DOMException; public String getPaddingLeft(); public void setPaddingLeft(String paddingLeft) throws DOMException; public String getPage(); public void setPage(String page) throws DOMException; public String getPageBreakAfter(); public void setPageBreakAfter(String pageBreakAfter) throws DOMException; public String getPageBreakBefore(); public void setPageBreakBefore(String pageBreakBefore) throws DOMException; public String getPageBreakInside(); public void setPageBreakInside(String pageBreakInside) throws DOMException; public String getPause(); public void setPause(String pause) throws DOMException; public String getPauseAfter(); public void setPauseAfter(String pauseAfter) throws DOMException; public String getPauseBefore(); public void setPauseBefore(String pauseBefore) throws DOMException; public String getPitch(); public void setPitch(String pitch) throws DOMException; public String getPitchRange(); public void setPitchRange(String pitchRange) throws DOMException; public String getPlayDuring(); public void setPlayDuring(String playDuring) throws DOMException; public String getPosition(); public void setPosition(String position) throws DOMException; public String getQuotes(); public void setQuotes(String quotes) throws DOMException; public String getRichness(); public void setRichness(String richness) throws DOMException; public String getRight(); public void setRight(String right) throws DOMException; public String getSize(); public void setSize(String size) throws DOMException; public String getSpeak(); public void setSpeak(String speak) throws DOMException; public String getSpeakHeader(); public void setSpeakHeader(String speakHeader) throws DOMException; public String getSpeakNumeral(); public void setSpeakNumeral(String speakNumeral) throws DOMException; public String getSpeakPunctuation(); public void setSpeakPunctuation(String speakPunctuation) throws DOMException; public String getSpeechRate(); public void setSpeechRate(String speechRate) throws DOMException; public String getStress(); public void setStress(String stress) throws DOMException; public String getTableLayout(); public void setTableLayout(String tableLayout) throws DOMException; public String getTextAlign(); public void setTextAlign(String textAlign) throws DOMException; public String getTextDecoration(); public void setTextDecoration(String textDecoration) throws DOMException; public String getTextIndent(); public void setTextIndent(String textIndent) throws DOMException; public String getTextShadow(); public void setTextShadow(String textShadow) throws DOMException; public String getTextTransform(); public void setTextTransform(String textTransform) throws DOMException; public String getTop(); public void setTop(String top) throws DOMException; public String getUnicodeBidi(); public void setUnicodeBidi(String unicodeBidi) throws DOMException; public String getVerticalAlign(); public void setVerticalAlign(String verticalAlign) throws DOMException; public String getVisibility(); public void setVisibility(String visibility) throws DOMException; public String getVoiceFamily(); public void setVoiceFamily(String voiceFamily) throws DOMException; public String getVolume(); public void setVolume(String volume) throws DOMException; public String getWhiteSpace(); public void setWhiteSpace(String whiteSpace) throws DOMException; public String getWidows(); public void setWidows(String widows) throws DOMException; public String getWidth(); public void setWidth(String width) throws DOMException; public String getWordSpacing(); public void setWordSpacing(String wordSpacing) throws DOMException; public String getZIndex(); public void setZIndex(String zIndex) throws DOMException; }
package org.w3c.dom.events; public class EventException extends RuntimeException { public EventException(short code, String message) { super(message); this.code = code; } public short code; // EventExceptionCode public static final short UNSPECIFIED_EVENT_TYPE_ERR = 0; }
package org.w3c.dom.events; public interface EventTarget { public void addEventListener(String type, EventListener listener, boolean useCapture); public void removeEventListener(String type, EventListener listener, boolean useCapture); public boolean dispatchEvent(Event evt) throws EventException; }
package org.w3c.dom.events; public interface EventListener { public void handleEvent(Event evt); }
package org.w3c.dom.events; import org.w3c.dom.Node; public interface Event { // PhaseType public static final short CAPTURING_PHASE = 1; public static final short AT_TARGET = 2; public static final short BUBBLING_PHASE = 3; public String getType(); public EventTarget getTarget(); public Node getCurrentNode(); public short getEventPhase(); public boolean getBubbles(); public boolean getCancelable(); public long getTimeStamp(); public void stopPropagation(); public void preventDefault(); public void initEvent(String eventTypeArg, boolean canBubbleArg, boolean cancelableArg); }
package org.w3c.dom.events; import org.w3c.dom.DOMException; public interface DocumentEvent { public Event createEvent(String eventType) throws DOMException; }
package org.w3c.dom.events; import org.w3c.dom.views.AbstractView; public interface UIEvent extends Event { public AbstractView getView(); public int getDetail(); public void initUIEvent(String typeArg, boolean canBubbleArg, boolean cancelableArg, AbstractView viewArg, int detailArg); }
package org.w3c.dom.events; import org.w3c.dom.Node; import org.w3c.dom.views.AbstractView; public interface MouseEvent extends UIEvent { public int getScreenX(); public int getScreenY(); public int getClientX(); public int getClientY(); public boolean getCtrlKey(); public boolean getShiftKey(); public boolean getAltKey(); public boolean getMetaKey(); public short getButton(); public Node getRelatedNode(); public void initMouseEvent(String typeArg, boolean canBubbleArg, boolean cancelableArg, AbstractView viewArg, int detailArg, int screenXArg, int screenYArg, int clientXArg, int clientYArg, boolean ctrlKeyArg, boolean altKeyArg, boolean shiftKeyArg, boolean metaKeyArg, short buttonArg, Node relatedNodeArg); }
package org.w3c.dom.events; import org.w3c.dom.Node; public interface MutationEvent extends Event { public Node getRelatedNode(); public String getPrevValue(); public String getNewValue(); public String getAttrName(); public void initMutationEvent(String typeArg, boolean canBubbleArg, boolean cancelableArg, Node relatedNodeArg, String prevValueArg, String newValueArg, String attrNameArg); }
package org.w3c.dom.traversal; import org.w3c.dom.DOMException; import org.w3c.dom.Node; public interface NodeIterator { public Node getRoot(); public int getWhatToShow(); public NodeFilter getFilter(); public boolean getExpandEntityReferences(); public Node nextNode() throws DOMException; public Node previousNode() throws DOMException; public void detach(); }
package org.w3c.dom.traversal; import org.w3c.dom.Node; public interface NodeFilter { // Constants returned by acceptNode public static final short FILTER_ACCEPT = 1; public static final short FILTER_REJECT = 2; public static final short FILTER_SKIP = 3; // Constants for whatToShow public static final int SHOW_ALL = 0xFFFFFFFF; public static final int SHOW_ELEMENT = 0x00000001; public static final int SHOW_ATTRIBUTE = 0x00000002; public static final int SHOW_TEXT = 0x00000004; public static final int SHOW_CDATA_SECTION = 0x00000008; public static final int SHOW_ENTITY_REFERENCE = 0x00000010; public static final int SHOW_ENTITY = 0x00000020; public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040; public static final int SHOW_COMMENT = 0x00000080; public static final int SHOW_DOCUMENT = 0x00000100; public static final int SHOW_DOCUMENT_TYPE = 0x00000200; public static final int SHOW_DOCUMENT_FRAGMENT = 0x00000400; public static final int SHOW_NOTATION = 0x00000800; public short acceptNode(Node n); }
package org.w3c.dom.traversal; import org.w3c.dom.DOMException; import org.w3c.dom.Node; public interface TreeWalker { public Node getRoot(); public int getWhatToShow(); public NodeFilter getFilter(); public boolean getExpandEntityReferences(); public Node getCurrentNode(); public void setCurrentNode(Node currentNode) throws DOMException; public Node parentNode(); public Node firstChild(); public Node lastChild(); public Node previousSibling(); public Node nextSibling(); public Node previousNode(); public Node nextNode(); }
package org.w3c.dom.traversal; import org.w3c.dom.DOMException; import org.w3c.dom.Node; public interface DocumentTraversal { public NodeIterator createNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion); public TreeWalker createTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion) throws DOMException; }
package org.w3c.dom.range; public class RangeException extends RuntimeException { public RangeException(short code, String message) { super(message); this.code = code; } public short code; // RangeExceptionCode public static final short BAD_BOUNDARYPOINTS_ERR = 1; public static final short INVALID_NODE_TYPE_ERR = 2; }
package org.w3c.dom.range; import org.w3c.dom.DOMException; import org.w3c.dom.DocumentFragment; import org.w3c.dom.Node; public interface Range { public Node getStartContainer() throws DOMException; public int getStartOffset() throws DOMException; public Node getEndContainer() throws DOMException; public int getEndOffset() throws DOMException; public boolean getCollapsed() throws DOMException; public Node getCommonAncestorContainer() throws DOMException; public void setStart(Node refNode, int offset) throws RangeException, DOMException; public void setEnd(Node refNode, int offset) throws RangeException, DOMException; public void setStartBefore(Node refNode) throws RangeException, DOMException; public void setStartAfter(Node refNode) throws RangeException, DOMException; public void setEndBefore(Node refNode) throws RangeException, DOMException; public void setEndAfter(Node refNode) throws RangeException, DOMException; public void collapse(boolean toStart) throws DOMException; public void selectNode(Node refNode) throws RangeException, DOMException; public void selectNodeContents(Node refNode) throws RangeException, DOMException; // CompareHow public static final short START_TO_START = 0; public static final short START_TO_END = 1; public static final short END_TO_END = 2; public static final short END_TO_START = 3; public short compareBoundaryPoints(short how, Range sourceRange) throws DOMException; public void deleteContents() throws DOMException; public DocumentFragment extractContents() throws DOMException; public DocumentFragment cloneContents() throws DOMException; public void insertNode(Node newNode) throws DOMException, RangeException; public void surroundContents(Node newParent) throws DOMException, RangeException; public Range cloneRange() throws DOMException; public String toString() throws DOMException; public void detach() throws DOMException; }
package org.w3c.dom.range; public interface DocumentRange { public Range createRange(); }
This appendix contains the complete ECMA Script binding for the Level 2 Document Object Model definitions. The definitions are divided into Core, HTML, StyleSheets, CSS, Events, Traversal, and Range.
index
is equivalent to
invoking the item method with that index.
index
is equivalent to
invoking the item method with that index.
index
is equivalent to
invoking the item method with that index.
index
is equivalent to
invoking the item method with that index.
index
is equivalent to
invoking the item method with that index.
index
is equivalent to
invoking the item method with that index.
index
is equivalent to
invoking the item method with that index.
index
is equivalent to
invoking the item method with that index.
The following example will add an ECMA Script based EventListener to the Node 'exampleNode':
// Given the Node 'exampleNode' // Define the EventListener function function clickHandler(evt) { // Function contents } // The following line will add a non-capturing 'click' listener // to 'exampleNode'. exampleNode.addEventListener("click", clickHandler, false);
Many people contributed to this specification, including members of the DOM Working Group and the DOM Interest Group. We especially thank the following:
Lauren Wood (SoftQuad Software Inc., chair), Arnaud Le Hors (W3C, W3C staff contact), Andrew Watson (Object Management Group), Andy Heninger (IBM), Ben Chang (Oracle), Bill Smith (Sun), Bill Shea (Merrill Lynch), Bob Sutor (IBM), Chris Lovett (Microsoft), Chris Wilson (Microsoft), David Brownell (Sun), David Singer (IBM), Don Park (invited), Eric Vasilik (Microsoft), Gavin Nicol (INSO), Ian Jacobs (W3C), James Clark (invited), James Davidson (Sun), Jared Sorensen (Novell), Joe Kesselman (IBM), Joe Lapp (webMethods), Jonathan Robie (Texcel Research and Software AG), Kim Adamson-Sharpe (SoftQuad Software Inc.), Laurence Cable (Sun), Mark Davis (IBM), Mark Scardina (Oracle), Martin Dürst (W3C), Mike Champion (ArborText and Software AG), Miles Sabin (Cromwell Media), Patti Lutsky (Arbortext), Paul Grosso (Arbortext), Peter Sharpe (SoftQuad Software Inc.), Phil Karlton (Netscape), Philippe Le Hégaret (W3C), Ramesh Lekshmynarayanan (Merrill Lynch), Ray Whitmer (iMall and Excite@Home), Rich Rollman (Microsoft), Rick Gessner (Netscape), Scott Isaacs (Microsoft), Sharon Adler (INSO), Steve Byrne (JavaSoft), Tim Bray (invited), Tom Pixley (Netscape), Vidur Apparao (Netscape), Vinod Anupam (Lucent).
Thanks to all those who have helped to improve this specification by sending suggestions and corrections.
Thanks to Joe English, author of cost for helping so much in allowing us to develop a framework that made the production of this specification possible.
Thanks to Jan Kärrman, author of html2ps for helping so much in creating the PostScript version of the specification.
Several of the following term definitions have been borrowed or modified from similar definitions in other W3C or standards documents. See the links within the definitions for more information.
DOMString
. This indicates that
indexing on a DOMString
occurs in units of 16 bits.
This must not be misunderstood to mean that a DOMString
can store arbitrary 16-bit units. A DOMString
is a
character string encoded in UTF-16; this means that the restrictions
of UTF-16 as well as the other relevant restrictions on character strings
must be maintained. A single character, for example in the form of a
numeric character reference, may correspond to one or two 16-bit units.NodeList
objects, and their
attributes are deeply equivalent.NodeList
objects are equivalent if they
have the same length, and the nodes corresponding by index
are deeply equivalent. NamedNodeMap
objects are equivalent if
they have the same length, they have same collection of names,
and the nodes corresponding by name in the maps are deeply
equivalent. DocumentType
nodes are equivalent if
they are equivalent as nodes, have the same names, and have
equivalent entities and attributes NamedNodeMap
objects.AbstractView | DocumentView |
DocumentStyle | LinkStyle | MediaList |
StyleSheet | StyleSheetList |
DocumentEvent | Event | EventException |
EventExceptionCode | EventListener | EventTarget |
MouseEvent | MutationEvent | UIEvent |
DocumentTraversal | NodeFilter | NodeIterator |
TreeWalker |
DocumentRange | Range | RangeException |
RangeExceptionCode |