tabs.remove()

1つ以上のタブを閉じます。

この関数は Promise を返す非同期関数です。

構文

js
var removing = browser.tabs.remove(
  tabIds, // integer or integer array
);

パラメーター

tabIds

integer または array of integer. 閉じるタブの ID を指定します。

戻り値

A Promise that will be fulfilled with no arguments when all the specified tabs have been removed or their beforeunload prompts have been handled. If any error occurs, the promise will be rejected with an error message.

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
remove

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

タブを1つだけ閉じる場合:

js
function onRemoved() {
  console.log(`Removed`);
}

function onError(error) {
  console.log(`Error: ${error}`);
}

var removing = browser.tabs.remove(2);
removing.then(onRemoved, onError);

複数のタブを閉じる場合:

js
function onRemoved() {
  console.log(`Removed`);
}

function onError(error) {
  console.log(`Error: ${error}`);
}

var removing = browser.tabs.remove([15, 14, 1]);
removing.then(onRemoved, onError);

Example extensions

メモ: この API は Chromium の chrome.tabs API に基づいています。 This documentation is derived from tabs.json in the Chromium code.Microsoft Edge での実装状況は Microsoft Corporation から提供されたものであり、ここでは Creative Commons Attribution 3.0 United States License に従っています。