Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 944867 of Permissions

  • Revision slug: Web/API/Permissions
  • Revision title: Permissions
  • Revision id: 944867
  • Created:
  • Creator: poiru
  • Is current revision? No
  • Comment

Revision Content

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

The Permissions interface of the Permissions API provides the core Permission API functionality, such as methods for querying and revoking permissions

Method

{{domxref("Permissions.query()")}}
Returns the user permission status for a given API.
{{domxref("Permissions.request()")}}
Requests permission to use a given API. This is not currently supported in any browser.
{{domxref("Permissions.revoke()")}}
Revokes the permission currently set on a given API. This is not currently supported in any browser.

Example

navigator.permissions.query({name:'geolocation'}).then(function(result) {
  if (result.status == 'granted') {
    showLocalNewsWithGeolocation();
  } else if (result.status == 'prompt') {
    showButtonToEnableLocalNews();
  }
  // Don't do anything if the permission was denied.
});

Specification

Specification Status Comment
{{SpecName('Permissions API', '#permissions-interface', 'Permissions')}} {{Spec2('Permissions API')}} Initial definition.

Browser Support

{{ CompatibilityTable() }}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatChrome(43.0)}} {{CompatGeckoDesktop(45)}} {{CompatUnknown()}} {{CompatUnknown()}} {{CompatUnknown()}}
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo()}} {{CompatChrome(43.0)}} {{CompatGeckoMobile(45)}} {{CompatUnknown()}} {{CompatUnknown()}} {{CompatUnknown()}} {{CompatUnknown()}} {{CompatChrome(43.0)}}

Revision Source

<p><span style="line-height:19.0909080505371px">{{APIRef("Permissions API")}}{{SeeCompatTable}}</span></p>

<p>The Permissions interface of the <a href="Permissions_API">Permissions API</a> provides the core Permission API functionality, such as methods for querying and revoking permissions</p>

<h2 id="Method">Method</h2>

<dl>
 <dt>{{domxref("Permissions.query()")}}</dt>
 <dd>Returns the user permission status for a given API.</dd>
 <dt>{{domxref("Permissions.request()")}}</dt>
 <dd>Requests permission to use a given API. This is not currently supported in any browser.</dd>
 <dt>{{domxref("Permissions.revoke()")}}</dt>
 <dd>Revokes the permission currently set on a given API. This is not currently supported in any browser.</dd>
</dl>

<h2 id="Example">Example</h2>

<pre class="brush: js">
navigator.permissions.query({name:'geolocation'}).then(function(result) {
  if (result.status == 'granted') {
    showLocalNewsWithGeolocation();
  } else if (result.status == 'prompt') {
    showButtonToEnableLocalNews();
  }
  // Don't do anything if the permission was denied.
});</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>{{ CompatibilityTable() }}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatChrome(43.0)}}</td>
   <td>{{CompatGeckoDesktop(45)}}</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>Feature</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>Basic support</td>
   <td>{{CompatNo()}}</td>
   <td>{{CompatChrome(43.0)}}</td>
   <td>{{CompatGeckoMobile(45)}}</td>
   <td>{{CompatUnknown()}}</td>
   <td>{{CompatUnknown()}}</td>
   <td>{{CompatUnknown()}}</td>
   <td>{{CompatUnknown()}}</td>
   <td>{{CompatChrome(43.0)}}</td>
  </tr>
 </tbody>
</table>
</div>
Revert to this revision