Skip to content

Latest commit

 

History

History
93 lines (73 loc) · 3.56 KB

File metadata and controls

93 lines (73 loc) · 3.56 KB
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 に従っています。