javascript implementation hasFeature( )
hasFeature( ) | Firefox/Netscape/NN 6 IE 5(Mac)/6(Win) Chrome/Safari/DOM 1 |
hasFeature("feature", "version") | |
Returns a Boolean true if the browser application supports (i.e., conforms to the required specifications of) a stated W3C DOM module and version. The closely related isSupported( ) method performs the same test on an individual node, allowing you to verify feature support for the current node type. Parameter values for the two methods are identical. |
|
It is up to the browser maker to validate that the DOM implemented in the browser conforms with each module before allowing the browser to return true for the module. That doesn't necessarily mean that the implementation is bug-free or consistent with other implementations. Caveat scriptor. |
|
In theory, you could use this method to verify module support prior to accessing a property or invoking a method. The following script fragment from the head portion of a document dynamically links a different external style sheet file for "true" CSS2 support: var cssFile; if (document.implementation.hasFeature("CSS", "2.0")) { cssFile = "styles/corpStyle2.css"; } else { cssFile = "styles/corpStyle1.css"; } document.write(<link rel='stylesheet' type='text/css' href='" + cssFile + "'>");" |
|
More browsers support this browser-wide method than the element-specific method, which may help more developers deploy it sooner. |
|
Parameters | |
|
|
Returned Value | |
Boolean value: true | false. |
Powered by Linode.