Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

tabs.duplicate()

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

Duplicates a tab, given its ID.

Syntax

chrome.tabs.duplicate(
  tabId,              // integer
  function(tab) {...} // optional function
)

This API is also available as browser.tabs.duplicate() in a version that returns a promise.

Parameters

tabId
integer. The ID of the tab which is to be duplicated.
callbackOptional
function. The function is passed the following arguments:
tabOptional
tabs.Tab. Details about the duplicated tab. The tabs.Tab object only contains url, title and favIconUrl if the extension has the "tabs" permission.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes No 47.0 No 33

Examples

Duplicate the first tab, and then log the ID of the newly created tab:

function onDuplicated(tabInfo) {
  console.log(tabInfo.id);
} 

// Duplicate the first tab in the array
function duplicateFirstTab(tabs) {console.log(tabs);
  if (tabs.length > 0) {
    chrome.tabs.duplicate(tabs[0].id, onDuplicated);
  }
}

// Query for all open tabs
chrome.tabs.query({}, duplicateFirstTab);

Example add-ons

Acknowledgements

This API is based on Chromium's chrome.tabs API. This documentation is derived from tabs.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

ドキュメントのタグと貢献者

 このページの貢献者: Makyen, wbamberg
 最終更新者: Makyen,