構文
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.
ブラウザーの互換性
Loading…
例
タブを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.