Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите сделать эту работу!
Вы можете также прочитать эту статью на English (US).

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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

Methods

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

Example

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

Specification

Specification Status Comment
Permissions
The definition of 'Permissions' in that specification.
Working Draft Initial definition.

Browser Support

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
PermissionsChrome Full support 43Edge ? Firefox Full support 46IE ? Opera Full support YesSafari No support NoWebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 46Opera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support Yes
accelerometer permissonChrome Full support 62Edge ? Firefox ? IE ? Opera ? Safari No support NoWebView Android Full support 62Chrome Android Full support 62Firefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android ?
accessibility events permissonChrome Full support 62Edge ? Firefox ? IE ? Opera ? Safari No support NoWebView Android Full support 62Chrome Android Full support 62Firefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android ?
ambient-light-sensor permissonChrome Full support 62Edge ? Firefox ? IE ? Opera ? Safari No support NoWebView Android Full support 62Chrome Android Full support 62Firefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android ?
accelerometer permissonChrome Full support 62Edge ? Firefox ? IE ? Opera ? Safari No support NoWebView Android Full support 62Chrome Android Full support 62Firefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android ?
camera permissionChrome Full support 64Edge ? Firefox ? IE ? Opera ? Safari No support NoWebView Android Full support 64Chrome Android Full support 64Firefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android ?
clipboard-read permissonChrome Full support 64Edge ? Firefox No support NoIE ? Opera ? Safari No support NoWebView Android Full support 64Chrome Android Full support 64Firefox Android No support NoOpera Android ? Safari iOS No support NoSamsung Internet Android ?
clipboard-write permissionChrome Full support 64Edge ? Firefox No support NoIE ? Opera ? Safari No support NoWebView Android Full support 64Chrome Android Full support 64Firefox Android No support NoOpera Android ? Safari iOS No support NoSamsung Internet Android ?
geolocation permissionChrome Full support 43Edge ? Firefox ? IE ? Opera Full support 30Safari No support NoWebView Android No support NoChrome Android Full support 43Firefox Android ? Opera Android Full support 30Safari iOS No support NoSamsung Internet Android ?
background-sync permissionChrome Full support 51Edge ? Firefox ? IE ? Opera ? Safari No support NoWebView Android Full support 51Chrome Android Full support 51Firefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android ?
magnetometer permissionChrome Full support 62Edge ? Firefox ? IE ? Opera ? Safari No support NoWebView Android Full support 62Chrome Android Full support 62Firefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android ?
microphone permissionChrome Full support 64Edge ? Firefox ? IE ? Opera ? Safari No support NoWebView Android Full support 64Chrome Android Full support 64Firefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android ?
midi permissionChrome Full support 43Edge ? Firefox ? IE ? Opera Full support 30Safari No support NoWebView Android No support NoChrome Android Full support 43Firefox Android ? Opera Android Full support 30Safari iOS No support NoSamsung Internet Android ?
notifications permissionChrome Full support 43Edge ? Firefox ? IE ? Opera Full support 30Safari No support NoWebView Android No support NoChrome Android Full support 43Firefox Android ? Opera Android Full support 30Safari iOS No support NoSamsung Internet Android ?
payment-handler permissionChrome Full support 66Edge ? Firefox ? IE ? Opera ? Safari No support NoWebView Android Full support 66Chrome Android Full support 66Firefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android ?
persistent-storage permissionChrome No support NoEdge ? Firefox Full support 53IE ? Opera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android Full support 53Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?
push permissionChrome Full support 43Edge ? Firefox ? IE ? Opera Full support 30Safari No support NoWebView Android No support NoChrome Android Full support 43Firefox Android ? Opera Android Full support 30Safari iOS No support NoSamsung Internet Android ?
queryChrome Full support 43Edge ? Firefox Full support 46IE ? Opera Full support YesSafari No support NoWebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 46Opera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support Yes
request
ExperimentalNon-standard
Chrome Full support 46Edge ? Firefox No support NoIE ? Opera ? Safari No support NoWebView Android Full support 46Chrome Android Full support 46Firefox Android No support NoOpera Android ? Safari iOS No support NoSamsung Internet Android ?
requestAll
ExperimentalNon-standard
Chrome Full support 48Edge ? Firefox No support NoIE ? Opera ? Safari No support NoWebView Android Full support 48Chrome Android Full support 48Firefox Android No support NoOpera Android ? Safari iOS No support NoSamsung Internet Android ?
revoke
ExperimentalNon-standard
Chrome Full support 46Edge ? Firefox Full support 51
Disabled
Full support 51
Disabled
Disabled From version 51: this feature is behind the dom.permissions.revoke.enable preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No support 47 — 51
IE ? Opera ? Safari No support NoWebView Android Full support 46Chrome Android Full support 46Firefox Android Full support 51
Disabled
Full support 51
Disabled
Disabled From version 51: this feature is behind the dom.permissions.revoke.enable preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No support 47 — 51
Opera Android ? Safari iOS No support NoSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
User must explicitly enable this feature.
User must explicitly enable this feature.

Метки документа и участники

Внесли вклад в эту страницу: mdnwebdocs-bot, sideshowbarker, fscholz, chrisdavidmills, Sheppy, ebidel, poiru, jpmedley
Обновлялась последний раз: mdnwebdocs-bot,