Stay organized with collections Save and categorize content based on your preferences.
DescriptionUse the chrome.windows
API to interact with browser windows. You can use this API to create, modify, and rearrange windows in the browser.
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"],
...
}
Concepts and usage 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.
ExamplesTo try this API, install the windows API example from the chrome-extension-samples repository.
Two windows, each with one tab. Types CreateTypeSpecifies what type of browser window to create. 'panel' is deprecated and is available only to existing allowlisted extensions on Chrome OS.
Enum"normal"
Specifies the window as a standard window.
"popup"
Specifies the window as a popup window.
"panel"
Specifies the window as a panel.
populate
boolean optional
If true, the windows.Window
object has a tabs
property that contains a list of the tabs.Tab
objects. The Tab
objects only contain the url
, pendingUrl
, title
, and favIconUrl
properties if the extension's manifest file includes the "tabs"
permission.
If set, the windows.Window
returned is filtered based on its type. If unset, the default filter is set to ['normal', 'popup']
.
Whether the window is set to be always on top.
Whether the window is currently the focused window.
The height of the window, including the frame, in pixels. In some circumstances a window may not be assigned a height
property; for example, when querying closed windows from the sessions
API.
The ID of the window. Window IDs are unique within a browser session. In some circumstances a window may not be assigned an ID
property; for example, when querying windows using the sessions
API, in which case a session ID may be present.
Whether the window is incognito.
The offset of the window from the left edge of the screen in pixels. In some circumstances a window may not be assigned a left
property; for example, when querying closed windows from the sessions
API.
sessionId
string optional
The session ID used to uniquely identify a window, obtained from the sessions
API.
The state of this browser window.
Array of tabs.Tab
objects representing the current tabs in the window.
The offset of the window from the top edge of the screen in pixels. In some circumstances a window may not be assigned a top
property; for example, when querying closed windows from the sessions
API.
The type of browser window this is.
The width of the window, including the frame, in pixels. In some circumstances a window may not be assigned a width
property; for example, when querying closed windows from the sessions
API.
The state of this browser window. In some circumstances a window may not be assigned a state
property; for example, when querying closed windows from the sessions
API.
"normal"
Normal window state (not minimized, maximized, or fullscreen).
"minimized"
Minimized window state.
"maximized"
Maximized window state.
"fullscreen"
Fullscreen window state.
"locked-fullscreen"
Locked fullscreen window state. This fullscreen state cannot be exited by user action and is available only to allowlisted extensions on Chrome OS.
The type of browser window this is. In some circumstances a window may not be assigned a type
property; for example, when querying closed windows from the sessions
API.
"normal"
A normal browser window.
"popup"
A browser popup.
"panel"
Deprecated in this API. A Chrome App panel-style window. Extensions can only see their own panel windows.
"app"
Deprecated in this API. A Chrome App window. Extensions can only see their app own windows.
"devtools"
A Developer Tools window.
The windowId value that represents the current window.
WINDOW_ID_NONEThe windowId value that represents the absence of a Chrome browser window.
Methods create()chrome.windows.create(
createData?: object,
): Promise<Window | undefined>
Creates (opens) a new browser window with any optional sizing, position, or default URL provided.
ParameterscreateData
object optional
If true
, opens an active window. If false
, opens an inactive window.
The height in pixels of the new window, including the frame. If not specified, defaults to a natural height.
incognito
boolean optional
Whether the new window should be an incognito window.
The number of pixels to position the new window from the left edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels.
setSelfAsOpener
boolean optional
If true
, the newly-created window's 'window.opener' is set to the caller and is in the same unit of related browsing contexts as the caller.
The initial state of the window. The minimized
, maximized
, and fullscreen
states cannot be combined with left
, top
, width
, or height
.
The ID of the tab to add to the new window.
The number of pixels to position the new window from the top edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels.
Specifies what type of browser window to create.
url
string | string[] optional
A URL or array of URLs to open as tabs in the window. Fully-qualified URLs must include a scheme, e.g., 'http://www.google.com', not 'www.google.com'. Non-fully-qualified URLs are considered relative within the extension. Defaults to the New Tab Page.
The width in pixels of the new window, including the frame. If not specified, defaults to a natural width.
chrome.windows.get(
windowId: number,
queryOptions?: QueryOptions,
): Promise<Window>
Gets details about a window.
getAll()chrome.windows.getAll(
queryOptions?: QueryOptions,
): Promise<Window[]>
Gets all windows.
getLastFocused()chrome.windows.getLastFocused(
queryOptions?: QueryOptions,
): Promise<Window>
Gets the window that was most recently focused — typically the window 'on top'.
remove()chrome.windows.remove(
windowId: number,
): Promise<void>
Removes (closes) a window and all the tabs inside it.
update()chrome.windows.update(
windowId: number,
updateInfo: object,
): Promise<Window>
Updates the properties of a window. Specify only the properties that to be changed; unspecified properties are unchanged.
ParametersdrawAttention
boolean optional
If true
, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if the window already has focus. Set to false
to cancel a previous drawAttention
request.
If true
, brings the window to the front; cannot be combined with the state 'minimized'. If false
, brings the next window in the z-order to the front; cannot be combined with the state 'fullscreen' or 'maximized'.
The height to resize the window to in pixels. This value is ignored for panels.
The offset from the left edge of the screen to move the window to in pixels. This value is ignored for panels.
The new state of the window. The 'minimized', 'maximized', and 'fullscreen' states cannot be combined with 'left', 'top', 'width', or 'height'.
The offset from the top edge of the screen to move the window to in pixels. This value is ignored for panels.
The width to resize the window to in pixels. This value is ignored for panels.
chrome.windows.onBoundsChanged.addListener(
callback: function,
)
Fired when a window has been resized; this event is only dispatched when the new bounds are committed, and not for in-progress changes.
ParametersThe callback
parameter looks like:
(window: Window) => void
chrome.windows.onCreated.addListener(
callback: function,
filters?: object,
)
Fired when a window is created.
ParametersThe callback
parameter looks like:
(window: Window) => void
Details of the created window.
Conditions that the window's type being created must satisfy. By default it satisfies ['normal', 'popup']
.
chrome.windows.onFocusChanged.addListener(
callback: function,
filters?: object,
)
Fired when the currently focused window changes. Returns chrome.windows.WINDOW_ID_NONE
if all Chrome windows have lost focus. Note: On some Linux window managers, WINDOW_ID_NONE
is always sent immediately preceding a switch from one Chrome window to another.
The callback
parameter looks like:
(windowId: number) => void
ID of the newly-focused window.
Conditions that the window's type being removed must satisfy. By default it satisfies ['normal', 'popup']
.
chrome.windows.onRemoved.addListener(
callback: function,
filters?: object,
)
Fired when a window is removed (closed).
ParametersThe callback
parameter looks like:
(windowId: number) => void
ID of the removed window.
Conditions that the window's type being removed must satisfy. By default it satisfies ['normal', 'popup']
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-11 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-11 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4