sidebarAction.isOpen() 编辑
Returns true
if the extension's sidebar is open in a given window.
This function accepts a windowId
as a parameter:
- If you supply
windowId
, the function will check the given browser window. - If you omit
windowId
, the function will check the topmost browser window.
This is an asynchronous function that returns a Promise
.
Syntax
let gettingIsOpen = browser.sidebarAction.isOpen(
details // object
)
Parameters
details
object
. An object optionally containing thewindowId
to check.windowId
Optionalinteger
. ID of a browser window to check. If omitted defaults towindows.WINDOW_ID_CURRENT
, which refers to the topmost browser window.
Return value
A Promise
that will be fulfilled with true
if the extension's sidebar is open in the given window, or 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 topmost window:
browser.sidebarAction.isOpen({}).then(result => {
console.log(result);
});
Check all open windows:
async function checkWindow(windowId) {
let result = await browser.sidebarAction.isOpen({windowId});
console.log(`window: ${windowId} status: ${result}`);
}
browser.windows.getAll().then(all => {
for (let {id} of all) {
checkWindow(id);
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论