This is an experimental technologyCheck the Browser compatibility table carefully before using this in production.
The supports()
method of the DOMTokenList
interface returns true
if a given token
is in the associated attribute's supported tokens. This method is intended to support feature detection.
Syntax
let trueOrFalse = element.supports(token)
Parameters
token
- A
DOMString
containing the token to query for.
Returns
A Boolean
indicating whether the token was found.
Example
let iframe = document.getElementById('display');
if (iframe.sandbox.supports('an-upcoming-feature')) {
// support code for mystery future feature
} else {
// fallback code
}
if (iframe.sandbox.supports('allow-scripts')) {
// instruct frame to run JavaScript
//
// (NOTE: This feature is well-supported; this is just an example!)
//
}
Specifications
Specification | Status | Comment |
---|---|---|
Credential Management Level 1 | Working Draft | Initial definition. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome
Full support 49 |
Edge
Full support 17 |
Firefox
Full support 49 |
IE
No support No |
Opera
Full support 36 |
Safari
Full support 10.1 |
WebView Android
Full support 49 |
Chrome Android
Full support 49 |
Firefox Android
Full support 49 |
Opera Android
Full support 36 |
Safari iOS
Full support 10.3 |
Samsung Internet Android
Full support 5.0 |
Legend
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
DOMTokenList.supports() by Mozilla Contributors is licensed under CC-BY-SA 2.5.