title | slug |
---|---|
tabs.duplicate() |
Mozilla/Add-ons/WebExtensions/API/tabs/duplicate |
{{AddonSidebar}}
ID で指定されたタブを複製します。
この関数は Promise
を返す非同期関数です。
var duplicating = browser.tabs.duplicate(
tabId, // integer
);
tabId
- :
integer
. 複製するタブの ID を指定します。
- :
A Promise
that will be fulfilled with a {{WebExtAPIRef('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.
{{Compat}}
1つ目のタブを複製し、新しく作られたタブの ID をログに残す例:
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);
{{WebExtExamples}}
Note
この 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 に従っています。