Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The name
read-only property of the PermissionStatus
interface returns the name of a requested permission.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The name
read-only property of the PermissionStatus
interface returns the name of a requested permission.
A read-only value that is identical to the name
argument passed to navigator.permissions.query()
.
function stateChangeListener() { console.log(this.name, 'permission status changed to', this.state); } function queryAndTrackPermission(permissionName) { navigator.permissions.query({name: permissionName}).then(function(permissionStatus) { console.log(permissionName, 'permission state is', permissionStatus.state); permissionStatus.onchange = stateChangeListener; }); }; queryAndTrackPermission('geolocation'); queryAndTrackPermission('midi');
Specification |
---|
Permissions # dom-permissionstatus-name |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
name |
No |
No |
93 |
No |
No |
No |
No |
No |
93 |
No |
No |
No |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus/name