files/en-us/mozilla/add-ons/webextensions/api/sidebaraction/isopen/index.md
Returns true if the extension's sidebar is open in a given window.
This function accepts a windowId as a parameter:
windowId, the function will check the given browser window.windowId, the function will check the topmost browser window.This is an asynchronous function that returns a Promise.
let gettingIsOpen = browser.sidebarAction.isOpen(
details // object
)
details
object. An object optionally containing the windowId to check.
windowId {{optional_inline}}
integer. ID of a browser window to check. If omitted defaults to {{WebExtAPIRef("windows.WINDOW_ID_CURRENT")}}, which refers to the topmost browser window.A Promise that will be fulfilled with true if the extension's sidebar is open in the given window, or false otherwise.
Check the topmost window:
browser.sidebarAction.isOpen({}).then((result) => {
console.log(result);
});
Check all open windows:
async function checkWindow(windowId) {
const result = await browser.sidebarAction.isOpen({ windowId });
console.log(`window: ${windowId} status: ${result}`);
}
browser.windows.getAll().then((all) => {
for (const { id } of all) {
checkWindow(id);
}
});
{{WebExtExamples}}
{{Compat}}