Section 25.86. DOMImplementation.hasFeature( ): determine whether the implementation supports a feature


25.86. DOMImplementation.hasFeature( ): determine whether the implementation supports a feature

DOM Level 1 Core:

25.86.1. Synopsis

 boolean hasFeature(String feature,                    String version); 

25.86.1.1. 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 table in the Description. 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.

25.86.1.2. Returns

true if the implementation completely supports the specified version of the specified feature; false otherwise. If no version number is specified, the method returns TRue if the implementation completely supports any version of the specified feature.

25.86.2. Description

The W3C DOM standard is modular, and implementations are not required to implement all modules or features of the standard. This method tests 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:

Feature

Description

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 stylesheets are implemented.

CSS

Interfaces that are specific to CSS stylesheets 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.


25.86.3. Example

You might use this method in code like the following:

 // Check whether the browser supports the DOM Level 2 Range API if (document.implementation &&     document.implementation.hasFeature &&     document.implementation.hasFeature("Range", "2.0")) {   // If so, use it here... } else {   // If not, fall back on code that doesn't require Range objects } 

25.86.4. See Also

Node.isSupported( )




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net