---
title: Navigator.permissions
slug: Web/API/Navigator/permissions
tags:
  - API
  - Permissions
  - 属性
translation_of: Web/API/Navigator/permissions
---
<p>{{APIRef("HTML DOM")}}{{SeeCompatTable}}</p>

<p><code><strong>permissions</strong></code> 是 <code><strong>Navigator</strong></code> 读属性,返回一个可用于查询或更新某些APIs(由<a href="/en-US/docs/Web/API/Permissions_API">Permissions API</a>覆盖)的权限状态的对象。</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox"><em>permissionsObj</em> = <em>globalObj</em>.navigator.permissions
</pre>

<h2 id="值">值</h2>

<p>一个 {{domxref("Permissions")}} 对象。</p>

<h2 id="例子">例子</h2>

<pre class="brush: js">navigator.permissions.query({name:'geolocation'}).then(function(result) {
  if (result.state === 'granted') {
    showMap();
  } else if (result.state === 'prompt') {
    showButtonToEnableMap();
  }
  // 如果被拒绝,请不要做任何操作。
});
</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">备注</th>
  </tr>
  <tr>
   <td>{{SpecName('Permissions API')}}</td>
   <td>{{Spec2('Permissions API')}}</td>
   <td>初始化定义</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器支持">浏览器支持</h2>

<div>{{ CompatibilityTable() }}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>功能</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>基础支持</td>
   <td>{{CompatChrome(43.0)}}</td>
   <td>{{CompatGeckoDesktop(46)}}</td>
   <td>{{CompatUnknown()}}</td>
   <td>{{CompatUnknown()}}</td>
   <td>{{CompatUnknown()}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>功能</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>基础支持</td>
   <td>{{CompatNo()}}</td>
   <td>{{CompatChrome(43.0)}}</td>
   <td>{{CompatGeckoMobile(46)}}</td>
   <td>{{CompatUnknown()}}<sup>[1]</sup></td>
   <td>{{CompatUnknown()}}</td>
   <td>{{CompatUnknown()}}</td>
   <td>{{CompatUnknown()}}</td>
   <td>{{CompatChrome(43.0)}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Firefox OS 现在采用自己的具有特殊工作方式的 Permissions API:参见  <a href="/en-US/docs/Web/API/Permissions_API_(Firefox_OS)">Permissions API (Firefox OS)</a>.</p>

<h2 id="See_also" name="See_also">参见</h2>

<ul>
 <li><a href="/en-US/docs/Web/API/Permissions_API">Permissions API</a></li>
 <li>{{domxref("Navigator")}}</li>
</ul>