Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/windows/oncreated/index.md
6555 views
------{{AddonSidebar()}}
Fired when a window is created.
Syntax
Events have three functions:
addListener(callback): Adds a listener to this event.
removeListener(listener): Stop listening to this event. The
listenerargument is the listener to remove.
hasListener(listener): Check whether a
listeneris registered for this event. Returnstrueif it is listening,falseotherwise.
addListener syntax
Parameters
callback: Function that will be called when this event occurs. The function will be passed the following arguments:
window: A {{WebExtAPIRef('windows.Window')}} object containing details of the window that was created.
Browser compatibility
{{Compat}}
Examples
Log the IDs of new windows as they are created:
{{WebExtExamples}}
Note: This API is based on Chromium's
chrome.windowsAPI. This documentation is derived fromwindows.jsonin the Chromium code.