ObsoleteThis feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
The Permissions.revoke()
method of the Permissions
interface reverts a currently set permission back to its default state, which is usually prompt
.
Syntax
This method is called on the global Permissions
object navigator.permissions
.
var revokePromise = navigator.permissions.revoke(descriptor);
Parameters
descriptor
- An object based on the
PermissionDescriptor
dictionary that sets options for the operation consisting of a comma-separated list of name-value pairs. The available options are:
name
- The name of the API whose permissions you want to query. Valid values are
'geolocation'
,'midi'
,'notifications'
, and'push'
. userVisibleOnly
: (Push only, not supported in Firefox — see the Browser compatibility section below) Indicates whether you want to show a notification for every message or be able to send silent push notifications. The default isfalse
.sysex
: (MIDI only) Indicates whether you need and/or receive system exclusive messages. The default isfalse
.
- The name of the API whose permissions you want to query. Valid values are
Note: As of Firefox 44, the permissions for Notifications and Push have been merged. If permission is granted (e.g. by the user, in the relevant permissions dialog), navigator.permissions.query()
will return true
for both notifications
and push
.
Note: The persistent-storage
permission allows an origin to use a persistent box (i.e persistent storage) for its storage, as per the Storage API.
Returns
A Promise
that calls its fulfillment handler with a PermissionStatus
object indicating the result of the request.
Exceptions
TypeError
- Retrieving the
PermissionDescriptor
information failed in some way, or the permission doesn't exist or is currently unsupported (e.g.midi
, orpush
withuserVisibleOnly
).
Example
This function can be used by an app to request that its own Geolocation API permission be revoked.
function revokePermission() {
navigator.permissions.revoke({name:'geolocation'}).then(function(result) {
report(result.state);
});
}
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome
Full support 46 |
Edge
Full support 79 |
Firefox Full support 51 Full support 51 Disabled' From version 51: this feature is behind the |
IE
No support No |
Opera
? |
Safari
No support No |
WebView Android
Full support 46 |
Chrome Android
Full support 46 |
Firefox Android Full support 51 Full support 51 Disabled' From version 51: this feature is behind the |
Opera Android
? |
Safari iOS
No support No |
Samsung Internet Android
Full support 5.0 |
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.
Permissions.revoke() by Mozilla Contributors is licensed under CC-BY-SA 2.5.