这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

features() 方法在 FeaturePolicy interface returns a list of names of all features supported by the User Agent. Feature whose name appears on the list might not be allowed by the Feature Policy of the current execution context and/or might not be accessible because of user's permissions.

句法

const supportedFeatures = FeaturePolicy.features()
					

参数

None.

返回值

A list of strings that represent names of all Feature Policy directives supported by the User Agent.

范例

The followin example logs all the supported directives in the console.

// Get the Feature Policy object
const featurePolicy = document.featurePolicy
// Retreive the list of all supported Feature Policy directives
const supportedDirectives = featurePolicy.features()
// Print out each directive into the console
for (const directive of supportedDirectives){
  console.log(directive)
}
					

规范

规范 状态 注释
Feature Policy
The definition of 'features' in that specification.
编者草案 初始定义。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
features Chrome 74 Edge 79 Firefox 70 IE No Opera 62 Safari No WebView Android 74 Chrome Android 74 Firefox Android No Opera Android No Safari iOS No Samsung Internet Android 11.0

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

用户必须明确启用此特征。

用户必须明确启用此特征。

元数据

  • 最后修改:
  1. FeaturePolicy