Mozilla's getting a new look. What do you think? https://mzl.la/brandsurvey

windows.remove()

Closes a window and all the tabs inside it, given the window's ID.

Note: If an error occurred (for example, because the window could not be found) then runtime.lastError will be set, and you should check for it in the callback.

Syntax

chrome.windows.remove(
  windowId,        // integer
  function() {...} // optional function
)

This API is also available as browser.windows.remove() in a version that returns a promise.

Parameters

windowId
integer. ID of the window to close.
callbackOptional
A function called — with no arguments — when the window has closed.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes No 45.0 No 33

Examples

When the user clicks a browser action's icon, close the window in which the icon was clicked:

function onRemoved() {
  if (chrome.runtime.lastError) {
    console.log(chrome.runtime.lastError);
  }
}

chrome.browserAction.onClicked.addListener((tab) => {
  chrome.windows.remove(tab.windowId, onRemoved);
});

Acknowledgements

This API is based on Chromium's chrome.windows API. This documentation is derived from windows.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: Makyen, chrisdavidmills, wbamberg
 Last updated by: Makyen,