Firefox Tomorrow

web api instance method

DOMTokenList: supports() method

View on MDN ↗

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

supports(token)

Parameters

  • token
    • : A string containing the token to query for.

Return value

A boolean value indicating whether the token was found.

Example

const 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

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.