过时
This 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.
Permissions.revoke()
方法在
权限
interface reverts a currently set permission back to its default state, which is usually
prompt
.
This method is called on the global
权限
对象
navigator.permissions
.
var revokePromise = navigator.permissions.revoke(descriptor);
descriptor
PermissionDescriptor
dictionary that sets options for the operation consisting of a comma-separated list of name-value pairs. The available options are:
名称
: The name of the API whose permissions you want to query. Valid values are
'geolocation'
,
'midi'
,
'notifications'
,和
'push'
.
userVisibleOnly
: (Push only, not supported in Firefox — see the
浏览器兼容性
section below) Indicates whether you want to show a notification for every message or be able to send silent push notifications. The default is
false
.
sysex
: (MIDI only) Indicates whether you need and/or receive system exclusive messages. The default is
false
.
注意
: 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()
将返回
true
for both
notifications
and
push
.
注意
:
persistent-storage
permission allows an origin to use a persistent box (i.e
persistent storage
) for its storage, as per the
存储 API
.
A
Promise
that calls its fulfillment handler with a
PermissionStatus
object indicating the result of the request.
TypeError
PermissionDescriptor
information failed in some way, or the permission doesn't exist or is currently unsupported (e.g.
midi
,或
push
with
userVisibleOnly
).
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);
});
}
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
revoke
非标
|
Chrome 46 | Edge 79 |
Firefox
51
Disabled
|
IE 不支持 No | Opera ? | Safari 不支持 No | WebView Android 46 | Chrome Android 46 |
Firefox Android
51
Disabled
|
Opera Android ? | Safari iOS 不支持 No | Samsung Internet Android 5.0 |
完整支持
不支持
兼容性未知
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
用户必须明确启用此特征。