FeaturePolicy: features() 方法

實驗性: 這是一項實驗性技術
在生產中使用此技術之前,請仔細檢查瀏覽器相容性表格

FeaturePolicy 介面的 features() 方法返回使用者代理支援的所有功能的名稱列表。名稱出現在列表中的功能可能不被當前執行上下文的 Permissions Policy 允許,或者可能因為使用者許可權而無法訪問。

語法

js
features()

引數

無。

返回值

一個字串列表,表示使用者代理支援的所有 Permissions Policy 指令的名稱。

示例

以下示例將所有支援的指令記錄到控制檯。

js
// Get the FeaturePolicy object
const featurePolicy = document.featurePolicy;

// Retrieve the list of all supported Permissions Policy directives
const supportedDirectives = featurePolicy.features();

// Print out each directive into the console
for (const directive of supportedDirectives) {
  console.log(directive);
}

規範

此特性似乎未在任何規範中定義。

瀏覽器相容性