tabs.create()

Creates a new tab.

Syntax

chrome.tabs.create(
  createProperties,   // object
  function(tab) {...} // optional function
)

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

Parameters

createProperties
object. Properties to give the new tab.
activeOptional
boolean. Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see windows.update). Defaults to true.
indexOptional
integer. The position the tab should take in the window. The provided value will be clamped to between zero and the number of tabs in the window.
openerTabIdOptional
integer. The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab.
pinnedOptional
boolean. Whether the tab should be pinned. Defaults to false.
selectedOptional
boolean. Whether the tab should become the selected tab in the window. Defaults to true.
This property is deprecated, and is not supported in Firefox. Use active instead.
urlOptional
string. The URL to navigate the tab to initially. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension. Defaults to the New Tab Page.
For security reasons, in Firefox, this may not be a privileged URL. So passing any of the following URLs will fail, with runtime.lastError being set to an error message:
  • chrome: URLs
  • javascript: URLs
  • data: URLs
  • privileged about: URLs (for example, about:config, about:addons, about:debugging) . Non-privileged URLs (e.g., about:blank) are allowed.
windowIdOptional
integer. The window to create the new tab in. Defaults to the current window.
callbackOptional
function. The function is passed the following arguments:
tab
tabs.Tab. Details about the created tab. Will contain the ID of the new tab.

Browser compatibility

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

Compatibility notes

Edge

  • 'selected', 'pinned', or 'openerTabId' are not supported.

Firefox

  • 'selected' is deprecated and not supported. Use 'active' instead.

Examples

The simplest way to call this function. Opens a new tab in the current window, at the highest index position, set to the new tab page:

chrome.tabs.create({});

Open "https://example.org" in a new tab:

chrome.tabs.create({url:"https://example.org"});

Open "https://example.org" in a new tab, and get the new tab's ID:

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

chrome.tabs.create({url:"https://example.org"}, onCreated);

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.

Document Tags and Contributors

 Contributors to this page: Makyen, Jeremie, wbamberg, kmaglione
 Last updated by: Makyen,