browserAction.isEnabled() 编辑
Returns true
if the browser action is enabled.
This is an asynchronous function that returns a Promise
.
Syntax
let gettingIsEnabled = browser.browserAction.isEnabled(
details // object
)
Parameters
details
object
. An object optionally containing thetabId
orwindowId
to check.tabId
Optionalinteger
. ID of a tab to check.windowId
Optionalinteger
. 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
BCD tables only load in the browser
The compatibility table in 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:
browser.browserAction.isEnabled({}).then(result => {
console.log(result);
});
Check the state of the currently active tab:
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论