Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

tabs.remove()

Closes one or more tabs.

Syntax

chrome.tabs.remove(
  tabIds,          // integer or integer array
  function() {...} // optional function
)

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

Parameters

tabIds
integer or array of integer. The tab or tabs to close.
callbackOptional
function. Called with no arguments when the tab(s) are removed. If any tabs can't be found, chrome.runtime.lastError is set and should be checked in this function.

Browser compatibility

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

Examples

Close a single tab:

function onRemoved() {
  if (chrome.runtime.lastError) {
    console.log("failed: " + chrome.runtime.lastError);
  } else {
    console.log("removed tabs");
  }
}

chrome.tabs.remove(4, onRemoved);

Close multiple tabs:

function onRemoved() {
  if (chrome.runtime.lastError) {
    console.log("failed: " + chrome.runtime.lastError);
  } else {
    console.log("removed tabs");
  }
}

chrome.tabs.remove([4, 2], onRemoved);

Example add-ons

Acknowledgements

This API is based on Chromium's chrome.tabs API. This documentation is derived from tabs.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, wbamberg
 Last updated by: Makyen,