此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。
DOMTokenList.supports()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2018年4月.
如果给定的token 位于关联属性支持的 token 列表中,则DOMTokenList 接口的supports() 方法返回true。这个方法旨在支持特性检查。
In this article
语法
js
supports(token);参数
token一个字符串,包含了用于查询的 token。
返回值
一个布尔值,表示是否查询到 token。
示例
js
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!) //}规范
| Specification |
|---|
| DOM> # ref-for-dom-domtokenlist-supports①> |