DOMImplementation.hasFeature( ) |
determine whether the implementation supports a
feature |
Availability
DOM Level 1 Core
Synopsis
boolean hasFeature(String feature,
String version);
Arguments
- feature
-
The name of the feature for which support is being tested. The set of
valid feature names for the DOM Level 2 standard is listed in the
upcoming table. Feature names are case-insensitive.
- version
-
The feature version number for which support is being tested, or
null or the empty string "" if
support for any version of the feature is sufficient. In the Level 2
DOM specification, supported version numbers are 1.0 and 2.0.
Returns
true if the implementation completely supports the
specified version of the specified feature, or
false otherwise. If no version number is
specified, the method returns true if the
implementation completely supports any version of the specified
feature.
Description
The W3C DOM standard is modular, and implementations are not required
to implement all modules or features of the standard. This method is
used to test whether a DOM implementation supports a named module of
the DOM specification. The availability information for each entry in
this DOM reference includes the name of the module. Note that
although Internet Explorer 5 and 5.5 include partial support for the
DOM Level 1 specification, this important method is not supported
before IE 6.
The complete set of module names that may be used as the
feature argument are shown in the
following table.
Core
|
Node, Element, Document, Text, and the other fundamental interfaces
required by all DOM implementations are implemented. All conforming
implementations must support this module.
|
HTML
|
HTMLElement, HTMLDocument, and the other HTML-specific interfaces are
implemented.
|
XML
|
Entity, EntityReference, ProcessingInstruction, Notation, and the
other node types that are useful only with XML documents are
implemented.
|
StyleSheets
|
Simple interfaces describing generic style sheets are implemented.
|
CSS
|
Interfaces that are specific to CSS style sheets are implemented.
|
CSS2
|
The CSS2Properties interface is implemented.
|
Events
|
The basic event-handling interfaces are implemented.
|
UIEvents
|
The interfaces for user-interface events are implemented.
|
MouseEvents
|
The interfaces for mouse events are implemented.
|
HTMLEvents
|
The interfaces for HTML events are implemented.
|
MutationEvents
|
The interfaces for document mutation events are implemented.
|
Range
|
The interfaces for manipulating ranges of a document are implemented.
|
Traversal
|
The interfaces for advanced document traversal are implemented.
|
Views
|
The interfaces for document views are implemented.
|
Example
You might use this method in code like the following:
// Check whether the browser supports the DOM Level 2 Traversal API
if (document.implementation &&
document.implementation.hasFeature &&
document.implementation.hasFeature("Traversal", "2.0")) {
// If so, use it here...
}
else {
// If not, traverse the document some other way
}
See Also
Node.isSupported( )
|