chrome.windows

Description

Use the chrome.windows API to interact with browser windows. You can use this API to create, modify, and rearrange windows in the browser.

Manifest

When requested, a windows.Window contains an array of tabs.Tab objects. You must declare the "tabs" permission in your manifest if you need access to the url, pendingUrl, title, or favIconUrl properties of tabs.Tab. For example:

{
  "name": "My extension",
  ...
  "permissions": ["tabs"],
  ...
}

The current window

Many functions in the extension system take an optional windowId argument, which defaults to the current window.

The current window is the window that contains the code that is currently executing. It's important to realize that this can be different from the topmost or focused window.

For example, say an extension creates a few tabs or windows from a single HTML file, and that the HTML file contains a call to tabs.query(). The current window is the window that contains the page that made the call, no matter what the topmost window is.

In the case of service workers, the value of the current window falls back to the last active window. Under some circumstances, there may be no current window for background pages.

Examples