Web/API/DOMTokenList/supports

From Get docs

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

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

supports

Experimental'

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.