Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/windows/remove/index.md
6557 views
------{{AddonSidebar()}}
Closes a window and all the tabs inside it, given the window's ID.
This is an asynchronous function that returns a Promise.
Syntax
Parameters
windowId:
integer. ID of the window to close.
Return value
A Promise that will be fulfilled with no arguments when the window has been closed. If any error occurs, the promise will be rejected with an error message.
Browser compatibility
{{Compat}}
Examples
When the user clicks a browser action's icon, close the window in which the icon was clicked:
Close the current, e.g. popup, window when the user clicks a button on the page:
In Firefox, the same could be achieved with the .allowScriptsToClose window creation property and window.close().
{{WebExtExamples}}
Note: This API is based on Chromium's
chrome.windowsAPI. This documentation is derived fromwindows.jsonin the Chromium code.