diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/permissions/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/permissions/index.html')
-rw-r--r-- | files/zh-cn/web/api/permissions/index.html | 59 |
1 files changed, 59 insertions, 0 deletions
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 +--- +<p>{{APIRef("Permissions API")}}{{SeeCompatTable}}</p> + +<p><a href="Permissions_API">Permissions API</a>的Permissions接口提供核心PermissionAPI功能,例如查询和撤消权限的方法。</p> + +<h2 id="方法">方法</h2> + +<dl> + <dt>{{domxref("Permissions.query","Permissions.query()")}}</dt> + <dd>返回给定API的用户权限状态。</dd> + <dt>{{domxref("Permissions.request","Permissions.request()")}}</dt> + <dd> + <p>请求使用给定API的权限,<span style="font-size: 1rem; letter-spacing: -0.00278rem;">目前此功能尚未在任何浏览器中被支持。</span></p> + </dd> + <dt>{{domxref("Permissions.requestAll","Permissions.requestAll()")}}</dt> + <dd>请求使用一组给定API的权限。目前此功能<span style="font-size: 1rem; letter-spacing: -0.00278rem;">尚</span>未在任何浏览器中被支持。</dd> + <dt>{{domxref("Permissions.revoke","Permissions.revoke()")}}</dt> + <dd>返回撤消当前在给定API上设置的权限。</dd> +</dl> + +<h2 id="Example">Example</h2> + +<pre class="brush: js">navigator.permissions.query({name:'geolocation'}).then(function(result) { + if (result.state === 'granted') { + showLocalNewsWithGeolocation(); + } else if (result.state === 'prompt') { + showButtonToEnableLocalNews(); + } + // 如果没有此权限则不什么也做 +});</pre> + +<h2 id="Specification">Specification</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName("Permissions API","#permissions-interface", "Permissions")}}</td> + <td>{{Spec2("Permissions API")}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_Support">Browser Support</h2> + +<div> + + +<p>{{Compat("api.Permissions")}}</p> +</div> |