From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/permissions/index.html | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 files/zh-cn/web/api/permissions/index.html (limited to 'files/zh-cn/web/api/permissions') diff --git a/files/zh-cn/web/api/permissions/index.html b/files/zh-cn/web/api/permissions/index.html new file mode 100644 index 0000000000..59a142023b --- /dev/null +++ b/files/zh-cn/web/api/permissions/index.html @@ -0,0 +1,59 @@ +--- +title: Permissions +slug: Web/API/Permissions +translation_of: Web/API/Permissions +--- +

{{APIRef("Permissions API")}}{{SeeCompatTable}}

+ +

Permissions API的Permissions接口提供核心PermissionAPI功能,例如查询和撤消权限的方法。

+ +

方法

+ +
+
{{domxref("Permissions.query","Permissions.query()")}}
+
返回给定API的用户权限状态。
+
{{domxref("Permissions.request","Permissions.request()")}}
+
+

请求使用给定API的权限,目前此功能尚未在任何浏览器中被支持。

+
+
{{domxref("Permissions.requestAll","Permissions.requestAll()")}}
+
请求使用一组给定API的权限。目前此功能未在任何浏览器中被支持。
+
{{domxref("Permissions.revoke","Permissions.revoke()")}}
+
返回撤消当前在给定API上设置的权限。
+
+ +

Example

+ +
navigator.permissions.query({name:'geolocation'}).then(function(result) {
+  if (result.state === 'granted') {
+    showLocalNewsWithGeolocation();
+  } else if (result.state === 'prompt') {
+    showButtonToEnableLocalNews();
+  }
+  // 如果没有此权限则不什么也做
+});
+ +

Specification

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Permissions API","#permissions-interface", "Permissions")}}{{Spec2("Permissions API")}}Initial definition.
+ +

Browser Support

+ +
+ + +

{{Compat("api.Permissions")}}

+
-- cgit v1.2.3-54-g00ecf