tabs.duplicate()
ID で指定されたタブを複製します。
この関数は Promise
を返す非同期関数です。
構文
js
var duplicating = browser.tabs.duplicate(
tabId, // integer
);
パラメーター
tabId
-
integer
. 複製するタブの ID を指定します。
戻り値
A Promise
that will be fulfilled with a tabs.Tab
object containing details about the duplicated tab. The Tab
object only contains url
, title
and favIconUrl
if the extension has the "tabs"
permission. If any error occurs the promise will be rejected with an error message.
ブラウザーの互換性
例
1つ目のタブを複製し、新しく作られたタブの ID をログに残す例:
js
function onDuplicated(tabInfo) {
console.log(tabInfo.id);
}
function onError(error) {
console.log(`Error: ${error}`);
}
// Duplicate the first tab in the array
function duplicateFirstTab(tabs) {
console.log(tabs);
if (tabs.length > 0) {
var duplicating = browser.tabs.duplicate(tabs[0].id);
duplicating.then(onDuplicated, onError);
}
}
// Query for all open tabs
var querying = browser.tabs.query({});
querying.then(duplicateFirstTab, onError);
Example extensions
メモ:
この API は Chromiums の 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 に従っています。