The Permissions interface of the Permissions API provides the core Permission API functionality, such as methods for querying and revoking permissions
The Permissions interface of the Permissions API provides the core Permission API functionality, such as methods for querying and revoking permissions
Permissions.query()
Returns the user permission status for a given API.
Permissions.request()
Experimental
Requests permission to use a given API. This is not currently supported in any browser.
Permissions.requestAll()
Experimental Non-standard
Requests permission to use a given set of APIs. This is not currently supported in any browser.
Permissions.revoke()
Deprecated
Revokes the permission currently set on a given API.
js
navigator.permissions.query({ name: "geolocation" }).then((result) => { if (result.state === "granted") { showLocalNewsWithGeolocation(); } else if (result.state === "prompt") { showButtonToEnableLocalNews(); } // Don't do anything if the permission was denied. });
Specification |
---|
Permissions # permissions-interface |
BCD tables only load in the browser
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Permissions