XML DOM hasFeature() method

Definition and usage

The hasFeature() method determines whether the DOM implementation supports a certain feature.

Syntax:

nodeObject.selectNodes(feature, version)
Parameter Description
feature

Feature name, used to determine which support is being tested. Features are case-insensitive.

The following table lists the set of valid feature names supported by the 2nd level DOM standard.

version

Version number, used to determine which support is being tested, or null.

If all versions of the feature are supported, it is an empty string (" ").

In the 2nd level DOM standard, the supported version numbers are 1.0 and 2.0.

Return value

If the current implementation fully supports the specified version of the specified feature, the return value is true, otherwise false. If the version number is not specified and the implementation fully supports all versions of the specified feature, the method also returns true.

Explaination

The W3C DOM standard is modular and does not require each implementation to implement all modules or features in the standard. This method is used to detect whether a DOM implementation supports the specified module of the DOM standard.

Note that although Internet Explorer 5 and 5.5 partially support the 1st level DOM standard, before IE 6, there was no implementation that supported this important method.

The following table lists the complete set of module names that can be used as the feature parameter.

Features Description
Core

The basic interfaces that all DOM implementations, such as Node, Element, Document, Text, and others, are required to implement

All implementations that comply with the DOM standard must support this module.

HTML Implement HTMLElement, HTMLDocument, and other HTML-specific interfaces.
XML Implement Entity, EntityReference, ProcessingInstruction, Notation, and other node types specific to XML documents.
StyleSheets Implement the simple interface for describing ordinary style sheets.
CSS Implement the interface for CSS style sheets.
CSS2 Implement the CSS2Properties interface.
Events Implement the basic event handling interface.
UIEvents Implement the interface for handling user interface events.
MouseEvents Implement the interface for handling mouse events.
HTMLEvents Implement the interface for handling HTML events.
MutationEvents Implement the interface for handling document change events.
Range Implement the interface for operating document ranges.
Traversal Implement the interface for advanced document traversal.
Views Implement the interface for handling document views.

See Also

Node.isSupported()