browserAction.enable()
为选项卡启用浏览器操作。默认情况下,浏览器操作在所有选项卡中都是启用的。
语法
js
browser.browserAction.enable(
tabId // 可选整数
)
参数
tabId
可选-
integer
。你想要启用浏览器操作的选项卡的 ID。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
enable |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full 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.
示例
点击时禁用浏览器操作,并在每次打开新选项卡时重新启用它:
js
browser.tabs.onCreated.addListener(() => {
browser.browserAction.enable();
});
browser.browserAction.onClicked.addListener(() => {
browser.browserAction.disable();
});
备注:
此 API 基于 Chromium 的 chrome.browserAction
API。该文档衍生自 Chromium 代码中的 browser_action.json
。