forked from mdn/translated-content
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[zh-cn]: sync translation for
Permissions
(mdn#19720)
- Loading branch information
1 parent
4bf8425
commit 03a269c
Showing
1 changed file
with
16 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,42 @@ | ||
--- | ||
title: Permissions | ||
slug: Web/API/Permissions | ||
l10n: | ||
sourceCommit: ee253ac58d71b2ed336b705ab97dbe93122b3e04 | ||
--- | ||
|
||
{{APIRef("Permissions API")}}{{SeeCompatTable}} | ||
{{APIRef("Permissions API")}}{{AvailableInWorkers}} | ||
|
||
[Permissions API](Permissions_API)的 Permissions 接口提供核心 PermissionAPI 功能,例如查询和撤消权限的方法。 | ||
[Permissions API](/zh-CN/docs/Web/API/Permissions_API) 的 **`Permissions`** 接口提供 Permission API 的核心功能,例如查询和撤消权限的方法。 | ||
|
||
## 方法 | ||
## 实例方法 | ||
|
||
- {{domxref("Permissions.query","Permissions.query()")}} | ||
- : 返回给定 API 的用户权限状态。 | ||
- {{domxref("Permissions.request","Permissions.request()")}} | ||
- : 请求使用给定 API 的权限,目前此功能尚未在任何浏览器中被支持。 | ||
- {{domxref("Permissions.requestAll","Permissions.requestAll()")}} | ||
- : 请求使用一组给定 API 的权限。目前此功能尚未在任何浏览器中被支持。 | ||
- {{domxref("Permissions.revoke","Permissions.revoke()")}} | ||
- : 返回撤消当前在给定 API 上设置的权限。 | ||
- {{domxref("Permissions.request","Permissions.request()")}} {{Experimental_Inline}} | ||
- : 请求使用给定 API 的权限。目前任何浏览器都不支持此功能。 | ||
- {{domxref("Permissions.requestAll","Permissions.requestAll()")}} {{Experimental_Inline}} {{Non-standard_Inline}} | ||
- : 请求使用一组给定 API 的权限。目前任何浏览器都不支持此功能。 | ||
- {{domxref("Permissions.revoke","Permissions.revoke()")}} {{Deprecated_Inline}} | ||
- : 撤消当前在给定 API 上设置的权限。 | ||
|
||
## Example | ||
## 示例 | ||
|
||
```js | ||
navigator.permissions.query({ name: "geolocation" }).then(function (result) { | ||
navigator.permissions.query({ name: "geolocation" }).then((result) => { | ||
if (result.state === "granted") { | ||
showLocalNewsWithGeolocation(); | ||
} else if (result.state === "prompt") { | ||
showButtonToEnableLocalNews(); | ||
} | ||
// 如果没有此权限则不什么也做 | ||
// 如果拒绝授予此权限则什么也不做。 | ||
}); | ||
``` | ||
|
||
## Specification | ||
## 规范 | ||
|
||
{{Specifications}} | ||
|
||
## Browser Support | ||
## 浏览器兼容性 | ||
|
||
{{Compat}} |