Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. HTTP
  3. 参考
  4. HTTP 标头
  5. Permissions-Policy
  6. Permissions-Policy: bluetooth

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

Permissions-Policy: bluetooth

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

实验性:这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

HTTPPermissions-Policy 标头的bluetooth 指令控制当前文档是否被允许使用Web Bluetooth API

具体来说,如果定义的策略不允许使用此特性,则由Navigator.bluetooth 返回的Bluetooth 对象的方法将会阻止访问:

语法

http
Permissions-Policy: bluetooth=<allowlist>;
<allowlist>

允许使用该特性的来源列表。请参阅Permissions-Policy > 语法了解更多详细信息。

默认策略

bluetooth 的默认允许列表为:self

示例

通用示例

SecureCorp Inc. 希望在所有浏览上下文中禁用 Web Bluetooth API,除了其自身的来源和来源https://example.com。它可以通过发送以下 HTTP 响应标头来定义权限策略:

http
Permissions-Policy: bluetooth=(self "https://example.com")

带有 <iframe> 元素

FastCorp Inc. 希望为除了特定的<iframe> 的所有跨来源的子框架禁用bluetooth。它可以通过发送以下 HTTP 响应标头来定义权限策略:

http
Permissions-Policy: bluetooth=(self https://other.com/blue)

然后在<iframe> 元素上包含一个allow 属性:

html
<iframe src="https://other.com/blue" allow="bluetooth"></iframe>

<iframe> 属性可以有选择地在某些框架中启用特性,而在其他框架中禁用这些特性,即使这些框架包含来自同一来源的文档。

规范

Specification
Web Bluetooth
# permissions-policy

浏览器兼容性

参见

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp