Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/windows/index.md
6552 views
---
title: windows slug: Mozilla/Add-ons/WebExtensions/API/windows page-type: webextension-api tags: - API - Add-ons - Extensions - Interface - Non-standard - Reference - WebExtensions - Windows browser-compat: webextensions.api.windows
---

{{AddonSidebar}}

Interact with browser windows. You can use this API to get information about open windows and to open, modify, and close windows. You can also listen for window open, close, and activate events.

Types

  • {{WebExtAPIRef("windows.WindowType")}}

    • : The type of browser window this is.

  • {{WebExtAPIRef("windows.WindowState")}}

    • : The state of this browser window.

  • {{WebExtAPIRef("windows.Window")}}

    • : Contains information about a browser window.

  • {{WebExtAPIRef("windows.CreateType")}}

    • : Specifies the type of browser window to create.

Constants

  • {{WebExtAPIRef("windows.WINDOW_ID_NONE")}}

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

  • {{WebExtAPIRef("windows.WINDOW_ID_CURRENT")}}

    • : A value that can be used in place of a windowId in some APIs to represent the current window.

Methods

  • {{WebExtAPIRef("windows.get()")}}

    • : Gets details about a window, given its ID.

  • {{WebExtAPIRef("windows.getCurrent()")}}

    • : Gets the current window.

  • {{WebExtAPIRef("windows.getLastFocused()")}}

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

  • {{WebExtAPIRef("windows.getAll()")}}

    • : Gets all windows.

  • {{WebExtAPIRef("windows.create()")}}

    • : Creates a new window.

  • {{WebExtAPIRef("windows.update()")}}

    • : Updates the properties of a window. Use this to move, resize, and (un)focus a window, etc.

  • {{WebExtAPIRef("windows.remove()")}}

    • : Closes a window, and all its tabs.

Events

  • {{WebExtAPIRef("windows.onCreated")}}

    • : Fired when a window is created.

  • {{WebExtAPIRef("windows.onRemoved")}}

    • : Fired when a window is closed.

  • {{WebExtAPIRef("windows.onFocusChanged")}}

    • : Fired when the currently focused window changes.

Browser compatibility

{{Compat}}

{{WebExtExamples("h2")}}

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