HTML - DOMTokenList supports() Method



HTML DOMTokenList supports() method returns boolean value representing whether the token specified in parameter is supported in DOMTokenList or not. This method is used for feature detection.

Syntax

domtokenlist.supports(token);

Parameter

This method accepts a single parameter as listed below.

Parameter Description
token It represents the name of token for which you want to check.

Return Value

It returns a boolean value where true represents the tokens which are supported and false if not supported.

Example of HTML DOMTokenList 'supports()' Method

The following examples check if "allow-popups" is supported by iframe element or not.

<!DOCTYPE html>
<html>
<head>
    <title>
        HTML DOMTokenList supports() Method
    </title>
</head>
<body>
    <iframe id="support"></iframe>
    <p>Click below to check.</p>
    <button onclick="fun()">Check</button>
    <p id="token"></p>
    <script>
        function fun() {
            let x = document.getElementById("support")
                .sandbox.supports("allow-popups");
            document.getElementById("token").innerHTML = x;
        }
    </script>
</body>
</html>

Supported Browsers

Method Chrome Edge Firefox Safari Opera
supports() Yes 49 Yes 17 Yes 49 Yes 10.1 Yes 36
html_dom.htm
Advertisements