browserAction.isEnabled()
Returns true
if the browser action is enabled.
This is an asynchronous function that returns a Promise
.
Syntax
js
let gettingIsEnabled = browser.browserAction.isEnabled(
details // object
)
Parameters
details
-
object
. An object optionally containing thetabId
orwindowId
to check.tabId
Optional-
integer
. ID of a tab to check. windowId
Optional-
integer
. ID of a window to check.
- If windowId and tabId are both supplied, the function fails.
- If windowId and tabId are both omitted, the global enabled/disabled status is returned.
Return value
A Promise
that will be fulfilled with true
if the extension's browser action is enabled, and false
otherwise.
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
isEnabled | |||||||
details.windowId parameter |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
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.
Examples
Check the global state:
js
browser.browserAction.isEnabled({}).then((result) => {
console.log(result);
});
Check the state of the currently active tab:
js
async function enabledInActiveTab() {
let tabs = await browser.tabs.query({
currentWindow: true,
active: true,
});
let enabled = await browser.browserAction.isEnabled({
tabId: tabs[0].id,
});
console.log(enabled);
}