HTMLIFrameElement: allow 屬性

Baseline 已廣泛支援

此特性已經十分成熟,可在許多裝置和瀏覽器版本上使用。自 2020 年 7 月以來,它已在各大瀏覽器中可用。

HTMLIFrameElement 介面的 allow 屬性指示為該 <iframe> 元素指定的 許可權策略。該策略根據請求的源,定義了 <iframe> 元素可用的功能(例如,對 microphonecamerabatteryweb-share等的訪問)。

allow 屬性指定的許可權策略是對 Permissions-Policy 頭部中指定的策略的進一步限制。它並不能替代該頭部。

有關更多詳細資訊,請參閱 <iframe> 的許可權策略語法

它反映了 <iframe> 元素的 allow 屬性。

一個字串,指示為此 <iframe> 元素指定的 許可權策略,每個策略之間必須用空格分隔。

示例

html
<iframe
  id="el"
  src="https://example.com"
  allow="geolocation 'self' https://a.example.com https://b.example.com; fullscreen 'none'"></iframe>
js
const el = document.getElementById("el");
console.log(el.allow); // Output: "geolocation 'self' https://a.example.com https://b.example.com; fullscreen 'none'"

有關更多可用示例,請參閱 <iframe> 元素中的許可權策略

規範

規範
HTML
# dom-iframe-allow

瀏覽器相容性

另見