Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
1
12
1
1
18
1

The blur event fires when an element has lost focus.

5
12
6
5.1
18
5

The Window.close() method closes the current window, or the window on which it was called.

1
12
1
1
18
1

The Window.closed read-only property indicates whether the referenced window is closed or not.

1
12
1
1
18
1

The DOMContentLoaded event fires when the HTML document has been completely parsed, and all deferred scripts ( and ) have downloaded and executed. It doesn't wait for other things like images, subframes, and async scripts to finish loading.

1
12
1
3.1
18
2

The error event is fired on a Window object when a resource failed to load or couldn't be used — for example if a script has an execution error.

10
12
6
5.1
18
5

Makes a request to bring the window to the front. It may fail due to user settings and the window isn't guaranteed to be frontmost before this method returns.

1
12
1
1
18
1

The focus event fires when an element has received focus.

5
12
6
5.1
18
5

The Window.frameElement property returns the element (such as iframe or object) in which the window is embedded.

1
12
1
3
18
1

Returns the window itself, which is an array-like object, listing the direct sub-frames of the current window.

1
12
1
1
18
1

The read-only innerHeight property of the Window interface returns the interior height of the window in pixels, including the height of the horizontal scroll bar, if present.

1
12
1
3
18
1

The read-only Window property innerWidth returns the interior width of the window in pixels (that is, the width of the window's layout viewport). That includes the width of the vertical scroll bar, if one is present.

1
12
1
3
18
1

Returns the number of frames (either frame or iframe elements) in the window.

1
12
1
1
18
1

The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets, scripts (including async, deferred, and module scripts), iframes, and images, except those that are loaded lazily. This is in contrast to Document/DOMContentLoaded_event, which is fired as soon as the page DOM has been loaded, without waiting for…

1
12
1
1.3
18
1

The moveBy() method of the Window interface moves the current window by a specified amount.

1
12
1
1
18
1

The moveTo() method of the Window interface moves the current window to the specified coordinates.

1
12
1
1
18
1

The Window.name property gets/sets the name of the window's browsing context.

1
12
1
1
18
1

The open() method of the Window interface loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name.

1
12
1
1
18
1
open (features parameter popup)

`features` parameter accepts `"popup"` value

98
98
96
98
open (once per event)

One `Window.open()` call per event

23
12
65
11
25
11

The Window interface's opener property returns a reference to the window that opened the window, either with Window.open, or by navigating a link with a target attribute.

1
12
1
1
18
1

The Window.outerHeight read-only property returns the height in pixels of the whole browser window, including any sidebar, window chrome, and window-resizing borders/handles.

1
12
1
3
18
3

Window.outerWidth read-only property returns the width of the outside of the browser window. It represents the width of the whole browser window including sidebar (if expanded), window chrome and window resizing borders/handles.

1
12
1
3
18
3

The Window.parent property is a reference to the parent of the current window or subframe.

1
12
1
1.3
18
1

The resize event fires when the document view (window) has been resized.

1
12
1
1.1
18
1

The Window.resizeBy() method resizes the current window by a specified amount.

1
12
1
1
18
1

The Window.resizeTo() method dynamically resizes the window.

1
12
1
1
18
1

The Window property screen returns a reference to the screen object associated with the window. The screen object, implementing the Screen interface, is a special object for inspecting properties of the screen on which the current window is being rendered.

1
12
1
1
18
1

The Window.screenLeft read-only property returns the horizontal distance, in CSS pixels, from the left border of the user's browser viewport to the left side of the screen.

1
12
64
1
18
1

The Window.screenTop read-only property returns the vertical distance, in CSS pixels, from the top border of the user's browser viewport to the top side of the screen.

1
12
64
1
18
1

The Window.screenX read-only property returns the horizontal distance, in CSS pixels, of the left border of the user's browser viewport to the left side of the screen.

1
12
1
1
18
1

The Window.screenY read-only property returns the vertical distance, in CSS pixels, of the top border of the user's browser viewport to the top edge of the screen.

1
12
1
1
18
1

The Window.self read-only property returns the window itself, as a WindowProxy. It can be used with dot notation on a window object (that is, window.self) or standalone (self). The advantage of the standalone notation is that a similar notation exists for non-window contexts, such as in Worker. By using self, you can refer to the global scope in a way that…

1
12
1
3
18
1

The window.stop() stops further resource loading in the current browsing context, equivalent to the stop button in the browser.

1
14
1
3
18
1

Returns a reference to the topmost window in the window hierarchy.

1
12
1
3
18
1

The window property of a Window object points to the window object itself.

1
12
1
3
18
1
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 2 item(s)
Implementation note
  • Apart from firing the event on `window` as other browsers do, Firefox also fires the event on the `document` object. See bug 1228802.
  • Before Firefox 24, the interface for this event is a plain `Event`, not `FocusEvent`.
Notes 1 item(s)
Implementation note
  • Before Chrome 95, script-closeability depended on having an opener, not on being created by web content.
Notes 1 item(s)
Implementation note
  • Before Firefox 128, script-closeability depended on having an opener, not on being created by web content.
Notes 1 item(s)
Implementation note
  • Before Chrome Android 95, script-closeability depended on having an opener, not on being created by web content.
Notes 1 item(s)
Implementation note
  • Starting in Chrome 66, opening a popup in fullscreen mode and calling this function will end fullscreen mode.
Notes 2 item(s)
Implementation note
  • Apart from firing the event on `window` as other browsers do, Firefox also fires the event on the `document` object. See bug 1228802.
  • Before Firefox 24, the interface for this event is a plain `Event`, not `FocusEvent`.
Notes 1 item(s)
Implementation note
  • From version 4 to 24, this property could give a wrong value before page load in certain circumstances (see bug 641188).
Notes 1 item(s)
Implementation note
  • This property returns the height of the visual viewport instead of the layout viewport. See bug 174362 for details.
Notes 1 item(s)
Implementation note
  • From version 4 to 24, this property could give a wrong value before page load in certain circumstances (see bug 641188).
Notes 1 item(s)
Implementation note
  • This property returns the width of the visual viewport instead of the layout viewport. See bug 174362 for details.
Notes 1 item(s)
Implementation note
  • Before Firefox 86, if a new page from another domain is loaded into a tab, then `window.name` is not set to an empty string, which can allow some cross-site attacks. See bug 1685089 and bug 444222.
Notes 2 item(s)
Limitation
  • This browser only partially implements this feature
Implementation note
  • This method will not function if the `target` parameter is unspecified or set to `_blank`.
Notes 1 item(s)
Implementation note
  • Chrome does not fire a `resize` event on page load.
Notes 1 item(s)
Implementation note
  • Before Edge 79, Edge fired a `resize` event on page load. This is no longer the case.
Notes 1 item(s)
Implementation note
  • Before Firefox 68, Firefox fired a `resize` event on page load. This is no longer the case.
Notes 1 item(s)
Implementation note
  • Chrome Android does not fire a `resize` event on page load.
Notes 1 item(s)
Implementation note
  • Since Firefox 7, it's no longer possible for a web site to change the default size of a window in a browser if the window wasn't created by `window.open` or contains more than one tab. See here for more details.
Notes 1 item(s)
Implementation note
  • Since Firefox 7, it's no longer possible for a web site to change the default size of a window in a browser if the window wasn't created by `window.open` or contains more than one tab. See here for more details.
Notes 1 item(s)
Implementation note
  • Before Firefox 28, Gecko was using device pixels instead of CSS pixels; in other words, it was assuming a value of `screenPixelsPerCSSPixel` of 1 for any device.
Notes 1 item(s)
Implementation note
  • Before Firefox 28, Gecko was using device pixels instead of CSS pixels; in other words, it was assuming a value of `screenPixelsPerCSSPixel` of 1 for any device.
Notes 1 item(s)
Implementation note
  • Starting in Firefox 6, this property is read only, as defined by the standard.

Syntax

JAVASCRIPT
window.onresize = (e) => console.log(e.currentTarget);
document.body.onresize = (e) => console.log(e.currentTarget);

Use cases

  • Using Window

    The Window interface represents a window containing a DOM document; the document property points to the DOM document loaded in that window.

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.