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

Not allowed in: Content scripts, Devtools pages

_CreateCreateData
_GetAllGetInfo
_UpdateUpdateInfo
GetInfo
Window
CreateType
WindowState
WindowType
onCreated
onFocusChanged
onRemoved
WINDOW_ID_CURRENT
WINDOW_ID_NONE
create
get
getAll
getCurrent
getLastFocused
remove
update
CreateType: "normal" | "popup" | "panel" | "detached_panel"

Specifies what type of browser window to create. The 'panel' and 'detached_panel' types create a popup unless the '--enable-panels' flag is set.

WindowState: "normal" | "minimized" | "maximized" | "fullscreen" | "docked"

The state of this browser window. Under some circumstances a Window may not be assigned state property, for example when querying closed windows from the sessions API.

WindowType: "normal" | "popup" | "panel" | "app" | "devtools"

The type of browser window this is. Under some circumstances a Window may not be assigned type property, for example when querying closed windows from the sessions API.

onCreated: WebExtEvent<(window: browser.windows.Window) => void>

Fired when a window is created.

Details of the window that was created.

onFocusChanged: WebExtEvent<(windowId: number) => void>

Fired when the currently focused window changes. Will be windows.WINDOW_ID_NONE if all browser windows have lost focus. Note: On some Linux window managers, WINDOW_ID_NONE will always be sent immediately preceding a switch from one browser window to another.

ID of the newly focused window.

onRemoved: WebExtEvent<(windowId: number) => void>

Fired when a window is removed (closed).

ID of the removed window.

WINDOW_ID_CURRENT: number

The windowId value that represents the current window.

WINDOW_ID_NONE: number

The windowId value that represents the absence of a browser window.

  • Gets all windows.

    Parameters

    • OptionalgetInfo: _GetAllGetInfo

      Specifies properties used to filter the windows.Window returned and to determine whether they should contain a list of the tabs.Tab objects.

    Returns Promise<browser.windows.Window[]>

  • Gets the window that was most recently focused — typically the window 'on top'.

    Parameters

    Returns Promise<browser.windows.Window>

  • Removes (closes) a window, and all the tabs inside it.

    Parameters

    • windowId: number

    Returns Promise<void>

  • Updates the properties of a window. Specify only the properties that you want to change; unspecified properties will be left unchanged.

    Parameters

    Returns Promise<browser.windows.Window>