Window

  • Revision slug: Web/API/Window
  • Revision title: Window
  • Revision id: 409933
  • Created:
  • Creator: Yoshino
  • Is current revision? No
  • Comment

Revision Content

{{DomRef}}

This section provides a brief reference for all of the methods, properties, and events available through the DOM window object. The window object implements the Window interface, which in turn inherits from the AbstractView interface. Some additional global functions, namespaces objects, and constructors, not typically associated with the window, but available on it, are listed in the JavaScript Reference.

The window object represents the window itself. The document property of a window points to the DOM document loaded in that window. A window for a given document can be obtained using the {{Domxref("document.defaultView")}} property.

In a tabbed browser, such as Firefox, each tab contains its own window object (and if you're writing an extension, the browser window itself is a separate window too - see Working with windows in chrome code for more information). That is, the window object is not shared between tabs in the same window. Some methods, namely {{Domxref("window.resizeTo")}} and {{Domxref("window.resizeBy")}} apply to the whole window and not to the specific tab the window object belongs to. Generally, anything that can't reasonably pertain to a tab pertains to the window instead.

Properties

{{domxref("window.applicationCache")}} {{gecko_minversion_inline("1.9")}}
An {{domxref("OfflineResourceList")}} object providing access to the offline resources for the window.
{{domxref("window.closed")}} {{Non-standard_inline}}
This property indicates whether the current window is closed or not.
window.Components
The entry point to many XPCOM features. Some properties, e.g. classes, are only available to sufficiently privileged code.
{{domxref("Console","window.console")}} {{Non-standard_inline}}
Returns a reference to the console object providing access to the browser's debugging console.
{{domxref("window.content")}} and window._content {{Non-standard_inline}}
Returns a reference to the content element in the current window. The variant with underscore is deprecated.
{{domxref("window.controllers")}}
Returns the XUL controller objects for the current chrome window.
{{domxref("window.crypto")}} {{Non-standard_inline}}
Returns the browser crypto object.
{{domxref("window.defaultStatus")}} {{Obsolete_inline("gecko23")}}
Gets/sets the status bar text for the given window.
{{domxref("window.dialogArguments")}} {{Fx_minversion_inline(3)}}
Gets the arguments passed to the window (if it's a dialog box) at the time {{domxref("window.showModalDialog()")}} was called. This is an {{Interface("nsIArray")}}.
{{domxref("window.directories")}} {{obsolete_inline}}
Synonym of {{domxref("window.personalbar")}}
{{domxref("window.document")}}
Returns a reference to the document that the window contains.
{{domxref("window.frameElement")}}
Returns the element in which the window is embedded, or null if the window is not embedded.
{{domxref("window.frames")}}
Returns an array of the subframes in the current window.
{{domxref("window.fullScreen")}} {{gecko_minversion_inline("1.9")}}
This property indicates whether the window is displayed in full screen or not.
window.globalStorage {{gecko_minversion_inline("1.8.1")}} {{Non-standard_inline}} {{Obsolete_inline("gecko13")}}
Unsupported since Gecko 13 (Firefox 13). Use {{domxref("Storage#localStorage","window.localStorage")}} instead.
Was: Multiple storage objects that are used for storing data across multiple pages.
{{domxref("window.history")}}
Returns a reference to the history object.
{{domxref("window.innerHeight")}}
Gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar.
{{domxref("window.innerWidth")}}
Gets the width of the content area of the browser window including, if rendered, the vertical scrollbar.
{{domxref("window.length")}}
Returns the number of frames in the window. See also {{domxref("window.frames")}}.
{{domxref("window.location")}}
Gets/sets the location, or current URL, of the window object.
{{domxref("window.locationbar")}}
Returns the locationbar object, whose visibility can be toggled in the window.
{{domxref("Storage#localStorage","window.localStorage")}} {{gecko_minversion_inline("1.9.1")}}
Returns a reference to the local storage object used to store data that may only be accessed by the origin that created it.
{{domxref("window.menubar")}}
Returns the menubar object, whose visibility can be toggled in the window.
{{domxref("window.messageManager")}} {{gecko_minversion_inline("2.0")}}
Returns the message manager object for this window.
{{domxref("window.mozAnimationStartTime")}} {{gecko_minversion_inline("2.0")}}
The time in milliseconds since epoch at which the current animation cycle began.
{{domxref("window.mozInnerScreenX")}} {{gecko_minversion_inline("1.9.2")}}
Returns the horizontal (X) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. See mozScreenPixelsPerCSSPixel in {{interface("nsIDOMWindowUtils")}} for a conversion factor to adapt to screen pixels if needed.
{{domxref("window.mozInnerScreenY")}} {{gecko_minversion_inline("1.9.2")}}
Returns the vertical (Y) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. See mozScreenPixelsPerCSSPixel for a conversion factor to adapt to screen pixels if needed.
{{domxref("window.mozPaintCount")}} {{gecko_minversion_inline("2.0")}}
Returns the number of times the current document has been rendered to the screen in this window. This can be used to compute rendering performance.
{{domxref("window.name")}}
Gets/sets the name of the window.
{{domxref("window.navigator")}}
Returns a reference to the navigator object.
{{domxref("window.opener")}}
Returns a reference to the window that opened this current window.
{{domxref("window.outerHeight")}}
Gets the height of the outside of the browser window.
{{domxref("window.outerWidth")}}
Gets the width of the outside of the browser window.
{{domxref("window.scrollX","window.pageXOffset")}}
An alias for {{domxref("window.scrollX")}}.
{{domxref("window.scrollY","window.pageYOffset")}}
An alias for {{domxref("window.scrollY")}}
{{domxref("window.parent")}}
Returns a reference to the parent of the current window or subframe.
{{domxref("window.performance")}}
Provides a hosting area for performance related attributes.
{{domxref("window.personalbar")}}
Returns the personalbar object, whose visibility can be toggled in the window.
{{domxref("window.pkcs11")}} {{obsolete_inline}}
Formerly provided access to install and remove PKCS11 modules. Now this property is always null.
window.returnValue {{Fx_minversion_inline(3)}}
The return value to be returned to the function that called {{domxref("window.showModalDialog()")}} to display the window as a modal dialog.
{{domxref("window.screen")}}
Returns a reference to the screen object associated with the window.
{{domxref("window.screen.availTop")}}
Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
{{domxref("window.screen.availLeft")}}
Returns the first available pixel available from the left side of the screen.
{{domxref("window.screen.availHeight")}}
Specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows.
{{domxref("window.screen.availWidth")}}
Returns the amount of horizontal space in pixels available to the window.
{{domxref("window.screen.colorDepth")}}
Returns the color depth of the screen.
{{domxref("window.screen.height")}}
Returns the height of the screen in pixels.
{{domxref("window.screen.left")}}
Returns the current distance in pixels from the left side of the screen.
{{domxref("window.screen.pixelDepth")}}
Gets the bit depth of the screen.
{{domxref("window.screen.top")}}
Returns the distance from the top of the screen.
{{domxref("window.screen.width")}}
Returns the width of the screen.
{{domxref("window.screenX")}}
Returns the horizontal distance of the left border of the user's browser from the left side of the screen.
{{domxref("window.screenY")}}
Returns the vertical distance of the top border of the user's browser from the top side of the screen.
{{domxref("window.scrollbars")}}
Returns the scrollbars object, whose visibility can be toggled in the window.
{{domxref("window.scrollMaxX")}}
The maximum offset that the window can be scrolled to horizontally.
(i.e., the document width minus the viewport width)
{{domxref("window.scrollMaxY")}}
The maximum offset that the window can be scrolled to vertically (i.e., the document height minus the viewport height).
{{domxref("window.scrollX")}}
Returns the number of pixels that the document has already been scrolled horizontally.
{{domxref("window.scrollY")}}
Returns the number of pixels that the document has already been scrolled vertically.
{{domxref("window.self")}}
Returns an object reference to the window object itself.
{{domxref("Storage#sessionStorage","window.sessionStorage")}} {{Fx_minversion_inline("2.0")}}
A storage object for storing data within a single page session.
{{domxref("window.sidebar")}}
Returns a reference to the window object of the sidebar.
{{domxref("window.status")}}
Gets/sets the text in the statusbar at the bottom of the browser.
{{domxref("window.statusbar")}}
Returns the statusbar object, whose visibility can be toggled in the window.
{{domxref("window.toolbar")}}
Returns the toolbar object, whose visibility can be toggled in the window.
{{domxref("window.top")}}
Returns a reference to the topmost window in the window hierarchy. This property is read only.
{{domxref("window.URL")}} {{gecko_minversion_inline("2.0")}}
A DOM URL object, which provides the {{domxref("window.URL.createObjectURL()")}} and {{domxref("window.URL.revokeObjectURL()")}} methods.
{{domxref("window.window")}}
Returns a reference to the current window.
window[0], window[1], etc.
Returns a reference to the window object in the frames. See {{domxref("window.frames")}} for more details.

Methods

{{domxref("element.addEventListener","window.addEventListener")}}
Register an event handler to a specific event type on the window.
{{domxref("window.alert")}}
Displays an alert dialog.
{{domxref("window.atob")}}
Decodes a string of data which has been encoded using base-64 encoding.
{{domxref("window.back")}}
Moves back one in the window history.
{{domxref("window.blur")}}
Sets focus away from the window.
{{domxref("window.btoa")}}
Creates a base-64 encoded ASCII string from a string of binary data.
{{domxref("window.captureEvents")}} {{Obsolete_inline(24)}}
Registers the window to capture all events of the specified type.
{{domxref("window.clearImmediate")}}
Cancels the repeated execution set using setImmediate.
{{domxref("window.clearInterval")}}
Cancels the repeated execution set using setInterval.
{{domxref("window.clearTimeout")}}
Cancels the repeated execution set using setTimeout.
{{domxref("window.close")}}
Closes the current window.
{{domxref("window.confirm")}}
Displays a dialog with a message that the user needs to respond to.
{{domxref("window.disableExternalCapture")}} {{Obsolete_inline(24)}}
{{todo("NeedsContents")}}
{{domxref("window.dispatchEvent")}}
{{todo("NeedsContents")}}
{{domxref("window.dump")}}
Writes a message to the console.
{{domxref("window.enableExternalCapture")}} {{Obsolete_inline(24)}}
{{todo("NeedsContents")}}
{{domxref("window.escape")}}
Encodes a string.
{{domxref("window.find")}}
Searches for a given string in a window.
{{domxref("window.focus")}}
Sets focus on the current window.
{{domxref("window.forward")}}
Moves the window one document forward in the history.
{{domxref("window.GeckoActiveXObject")}}
{{todo("NeedsContents")}}
{{domxref("window.getAttention")}}
Flashes the application icon.
{{domxref("window.getAttentionWithCycleCount")}}
{{todo("NeedsContents")}}
{{domxref("window.getComputedStyle")}}
Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element.
{{domxref("window.getDefaulComputedStyle")}}
Gets default computed style for the specified element, ignoring author stylesheets.
{{domxref("window.getSelection")}}
Returns the selection object representing the selected item(s).
{{domxref("window.home")}}
Returns the browser to the home page.
{{domxref("window.matchMedia")}} {{gecko_minversion_inline("6.0")}}
Returns a {{domxref("MediaQueryList")}} object representing the specified media query string.
{{domxref("window.maximize")}}
{{todo("NeedsContents")}}
{{domxref("window.minimize")}} (top-level XUL windows only)
Minimizes the window.
{{domxref("window.moveBy")}}
Moves the current window by a specified amount.
{{domxref("window.moveTo")}}
Moves the window to the specified coordinates.
{{domxref("window.mozRequestAnimationFrame")}} {{gecko_minversion_inline("2.0")}}
Tells the browser that an animation is in progress, requesting that the browser schedule a repaint of the window for the next animation frame. This will cause a MozBeforePaint event to fire before that repaint occurs.
{{domxref("window.open")}}
Opens a new window.
{{domxref("window.openDialog")}}
Opens a new dialog window.
{{domxref("window.postMessage")}} {{Fx_minversion_inline(3)}}
Provides a secure means for one window to send a string of data to another window, which need not be within the same domain as the first, in a secure manner.
{{domxref("window.print")}}
Opens the Print Dialog to print the current document.
{{domxref("window.prompt")}}
Returns the text entered by the user in a prompt dialog.
{{domxref("window.QueryInterface")}}
{{todo("NeedsContents")}}
{{domxref("window.releaseEvents")}} {{Obsolete_inline(24)}}
Releases the window from trapping events of a specific type.
{{domxref("element.removeEventListener","window.removeEventListener")}}
Removes an event listener from the window.
{{domxref("window.resizeBy")}}
Resizes the current window by a certain amount.
{{domxref("window.resizeTo")}}
Dynamically resizes window.
{{domxref("window.restore")}}
{{todo("NeedsContents")}}
{{domxref("window.routeEvent")}} {{Obsolete_inline(24)}}
{{todo("NeedsContents")}}
{{domxref("window.scroll")}}
Scrolls the window to a particular place in the document.
{{domxref("window.scrollBy")}}
Scrolls the document in the window by the given amount.
{{domxref("window.scrollByLines")}}
Scrolls the document by the given number of lines.
{{domxref("window.scrollByPages")}}
Scrolls the current document by the specified number of pages.
{{domxref("window.scrollTo")}}
Scrolls to a particular set of coordinates in the document.
{{domxref("window.setCursor")}}
Changes the cursor for the current window
{{domxref("window.setImmediate")}}
Execute a function after the browser has finished other heavy tasks
{{domxref("window.setInterval")}}
Execute a function each X milliseconds.
{{domxref("window.setResizable")}}
{{todo("NeedsContents")}}
{{domxref("window.setTimeout")}}
Sets a delay for executing a function.
{{domxref("window.showModalDialog")}} {{Fx_minversion_inline(3)}}
Displays a modal dialog.
{{domxref("window.sizeToContent")}}
Sizes the window according to its content.
{{domxref("window.stop")}}
This method stops window loading.
{{domxref("window.unescape")}}
Unencodes a value that has been encoded in hexadecimal (e.g. a cookie).
{{domxref("window.updateCommands")}}
Updates the state of commands of the current chrome window (UI).
{{domxref("window.XPCNativeWrapper")}}
{{todo("NeedsContents")}}
{{domxref("window.XPCSafeJSObjectWrapper")}}

Event handlers

These are properties of the window object that can be set to establish event handlers for the various things that can happen in the window that might be of interest.

{{gecko_callout_heading("9.0")}}

Starting in Gecko 9.0 {{geckoRelease("9.0")}}, you can now use the syntax if ("onabort" in window) to determine whether or not a given event handler property exists. This is because event handler interfaces have been updated to be proper web IDL interfaces. See DOM event handlers for details.

{{domxref("window.onabort")}}
An event handler property for abort events on the window.
{{domxref("window.onbeforeunload")}}
An event handler property for before-unload events on the window.
{{domxref("window.onblur")}}
An event handler property for blur events on the window.
{{domxref("window.onchange")}}
An event handler property for change events on the window.
{{domxref("window.onclick")}}
An event handler property for click events on the window.
{{domxref("window.onclose")}}
An event handler property for handling the window close event.
{{domxref("window.oncontextmenu")}}
An event handler property for right-click events on the window.
{{domxref("window.ondevicelight")}}
An event handler property for any ambient light levels changes
{{domxref("window.ondevicemotion")}} {{gecko_minversion_inline("6.0")}}
{{todo("NeedsContents")}}
{{domxref("window.ondeviceorientation")}} {{gecko_minversion_inline("6.0")}}
{{todo("NeedsContents")}}
{{domxref("window.ondeviceproximity")}}
An event handler property for device proximity event
{{domxref("window.ondragdrop")}}
An event handler property for drag and drop events on the window.
{{domxref("window.onerror")}}
An event handler property for errors raised on the window.
{{domxref("window.onfocus")}}
An event handler property for focus events on the window.
{{domxref("window.onhashchange")}} {{gecko_minversion_inline("1.9.2")}}
An event handler property for hash change events on the window; called when the part of the URL after the hash mark ("#") changes.
{{domxref("window.onkeydown")}}
An event handler property for keydown events on the window.
{{domxref("window.onkeypress")}}
An event handler property for keypress events on the window.
{{domxref("window.onkeyup")}}
An event handler property for keyup events on the window.
{{domxref("window.onload")}}
An event handler property for window loading.
{{domxref("window.onmousedown")}}
An event handler property for mousedown events on the window.
{{domxref("window.onmousemove")}}
An event handler property for mousemove events on the window.
{{domxref("window.onmouseout")}}
An event handler property for mouseout events on the window.
{{domxref("window.onmouseover")}}
An event handler property for mouseover events on the window.
{{domxref("window.onmouseup")}}
An event handler property for mouseup events on the window.
{{domxref("window.onmozbeforepaint")}} {{gecko_minversion_inline("2.0")}}
An event handler property for the MozBeforePaint event, which is sent before repainting the window if the event has been requested by a call to the {{domxref("window.mozRequestAnimationFrame()")}} method.
{{domxref("window.onpaint")}}
An event handler property for paint events on the window.
{{domxref("window.onpopstate")}} {{gecko_minversion_inline("2.0")}}
An event handler property for popstate events, which are fired when navigating to a session history entry representing a state object.
{{domxref("window.onreset")}}
An event handler property for reset events on the window.
{{domxref("window.onresize")}}
An event handler property for window resizing.
{{domxref("window.onscroll")}}
An event handler property for window scrolling.
{{domxref("window.onselect")}}
An event handler property for window selection.
{{domxref("window.onsubmit")}}
An event handler property for submits on window forms.
{{domxref("window.onunload")}}
An event handler property for unload events on the window.
{{domxref("window.onuserproximity")}}
An event handler property for user proximity events
{{domxref("window.onpageshow")}}
An event handler property for pageshow events on the window.
{{domxref("window.onpagehide")}}
An event handler property for pagehide events on the window.

Constructors

{{domxref("Image")}}
Used for creating an {{domxref("HTMLImageElement")}}.
{{domxref("Option")}}
Used for creating an {{domxref("HTMLOptionElement")}}
{{domxref("Worker")}}
Used for creating a Web worker
 

See also

Revision Source

<div>
  {{DomRef}}</div>
<p>This section provides a brief reference for all of the methods, properties, and events available through the DOM <code>window</code> object. The <code>window</code> object implements the <code>Window</code> interface, which in turn inherits from the <code><a href="http://www.w3.org/TR/DOM-Level-2-Views/views.html#Views-AbstractView">AbstractView</a></code> interface. Some additional global functions, namespaces objects, and constructors, not typically associated with the window, but available on it, are listed in the <a href="/en-US/docs/JavaScript/Reference" title="https://developer.mozilla.org/en/JavaScript/Reference">JavaScript Reference</a>.</p>
<p>The <code>window</code> object represents the window itself. The <code>document</code> property of a <code>window</code> points to the <a href="/en-US/docs/DOM/document" title="DOM/document">DOM document</a> loaded in that window. A window for a given document can be obtained using the {{Domxref("document.defaultView")}} property.</p>
<p>In a tabbed browser, such as Firefox, each tab contains its own <code>window</code> object (and if you're writing an extension, the browser window itself is a separate window too - see <a href="/en-US/docs/Working_with_windows_in_chrome_code#Content_windows" title="Working_with_windows_in_chrome_code#Content_windows">Working with windows in chrome code</a> for more information). That is, the <code>window</code> object is not shared between tabs in the same window. Some methods, namely {{Domxref("window.resizeTo")}} and {{Domxref("window.resizeBy")}} apply to the whole window and not to the specific tab the <code>window</code> object belongs to. Generally, anything that can't reasonably pertain to a tab pertains to the window instead.</p>
<h2 id="Properties">Properties</h2>
<dl>
  <dt>
    {{domxref("window.applicationCache")}} {{gecko_minversion_inline("1.9")}}</dt>
  <dd>
    An {{domxref("OfflineResourceList")}} object providing access to the offline resources for the window.</dd>
  <dt>
    {{domxref("window.closed")}} {{Non-standard_inline}}</dt>
  <dd>
    This property indicates whether the current window is closed or not.</dd>
  <dt>
    <code><a href="/en-US/docs/Components_object" title="Components_object">window.Components</a></code></dt>
  <dd>
    The entry point to many <a href="/en-US/docs/XPCOM" title="XPCOM">XPCOM</a> features. Some properties, e.g. <a href="/en-US/docs/Components.classes" title="Components.classes">classes</a>, are only available to sufficiently privileged code.</dd>
  <dt>
    {{domxref("Console","window.console")}} {{Non-standard_inline}}</dt>
  <dd>
    Returns a reference to the console object providing access to the browser's debugging console.</dd>
  <dt>
    {{domxref("window.content")}} and window._content {{Non-standard_inline}}</dt>
  <dd>
    Returns a reference to the content element in the current window. The variant with underscore is deprecated.</dd>
  <dt>
    {{domxref("window.controllers")}}</dt>
  <dd>
    Returns the XUL controller objects for the current chrome window.</dd>
  <dt>
    {{domxref("window.crypto")}} {{Non-standard_inline}}</dt>
  <dd>
    Returns the browser crypto object.</dd>
  <dt>
    {{domxref("window.defaultStatus")}} {{Obsolete_inline("gecko23")}}</dt>
  <dd>
    Gets/sets the status bar text for the given window.</dd>
  <dt>
    {{domxref("window.dialogArguments")}} {{Fx_minversion_inline(3)}}</dt>
  <dd>
    Gets the arguments passed to the window (if it's a dialog box) at the time {{domxref("window.showModalDialog()")}} was called. This is an {{Interface("nsIArray")}}.</dd>
  <dt>
    {{domxref("window.directories")}} {{obsolete_inline}}</dt>
  <dd>
    Synonym of {{domxref("window.personalbar")}}</dd>
  <dt>
    {{domxref("window.document")}}</dt>
  <dd>
    Returns a reference to the document that the window contains.</dd>
  <dt>
    {{domxref("window.frameElement")}}</dt>
  <dd>
    Returns the element in which the window is embedded, or null if the window is not embedded.</dd>
  <dt>
    {{domxref("window.frames")}}</dt>
  <dd>
    Returns an array of the subframes in the current window.</dd>
  <dt>
    {{domxref("window.fullScreen")}} {{gecko_minversion_inline("1.9")}}</dt>
  <dd>
    This property indicates whether the window is displayed in full screen or not.</dd>
  <dt>
    <code>window.globalStorage </code>{{gecko_minversion_inline("1.8.1")}} {{Non-standard_inline}} {{Obsolete_inline("gecko13")}}</dt>
  <dd>
    Unsupported since Gecko 13 (Firefox 13). Use {{domxref("Storage#localStorage","window.localStorage")}} instead.<br />
    Was: Multiple storage objects that are used for storing data across multiple pages.</dd>
  <dt>
    {{domxref("window.history")}}</dt>
  <dd>
    Returns a reference to the history object.</dd>
  <dt>
    {{domxref("window.innerHeight")}}</dt>
  <dd>
    Gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar.</dd>
  <dt>
    {{domxref("window.innerWidth")}}</dt>
  <dd>
    Gets the width of the content area of the browser window including, if rendered, the vertical scrollbar.</dd>
  <dt>
    {{domxref("window.length")}}</dt>
  <dd>
    Returns the number of frames in the window. See also {{domxref("window.frames")}}.</dd>
  <dt>
    {{domxref("window.location")}}</dt>
  <dd>
    Gets/sets the location, or current URL, of the window object.</dd>
  <dt>
    {{domxref("window.locationbar")}}</dt>
  <dd>
    Returns the locationbar object, whose visibility can be toggled in the window.</dd>
  <dt>
    {{domxref("Storage#localStorage","window.localStorage")}} {{gecko_minversion_inline("1.9.1")}}</dt>
  <dd>
    Returns a reference to the local storage object used to store data that may only be accessed by the origin that created it.</dd>
  <dt>
    {{domxref("window.menubar")}}</dt>
  <dd>
    Returns the menubar object, whose visibility can be toggled in the window.</dd>
  <dt>
    {{domxref("window.messageManager")}} {{gecko_minversion_inline("2.0")}}</dt>
  <dd>
    Returns the <a href="/en-US/docs/The_message_manager" title="The message manager">message manager</a> object for this window.</dd>
  <dt>
    {{domxref("window.mozAnimationStartTime")}} {{gecko_minversion_inline("2.0")}}</dt>
  <dd>
    The time in milliseconds since epoch at which the current animation cycle began.</dd>
  <dt>
    {{domxref("window.mozInnerScreenX")}} {{gecko_minversion_inline("1.9.2")}}</dt>
  <dd>
    Returns the horizontal (X) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. See <code>mozScreenPixelsPerCSSPixel</code> in {{interface("nsIDOMWindowUtils")}} for a conversion factor to adapt to screen pixels if needed.</dd>
  <dt>
    {{domxref("window.mozInnerScreenY")}} {{gecko_minversion_inline("1.9.2")}}</dt>
  <dd>
    Returns the vertical (Y) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. See <code>mozScreenPixelsPerCSSPixel</code> for a conversion factor to adapt to screen pixels if needed.</dd>
  <dt>
    {{domxref("window.mozPaintCount")}} {{gecko_minversion_inline("2.0")}}</dt>
  <dd>
    Returns the number of times the current document has been rendered to the screen in this window. This can be used to compute rendering performance.</dd>
  <dt>
    {{domxref("window.name")}}</dt>
  <dd>
    Gets/sets the name of the window.</dd>
  <dt>
    {{domxref("window.navigator")}}</dt>
  <dd>
    Returns a reference to the navigator object.</dd>
  <dt>
    {{domxref("window.opener")}}</dt>
  <dd>
    Returns a reference to the window that opened this current window.</dd>
  <dt>
    {{domxref("window.outerHeight")}}</dt>
  <dd>
    Gets the height of the outside of the browser window.</dd>
  <dt>
    {{domxref("window.outerWidth")}}</dt>
  <dd>
    Gets the width of the outside of the browser window.</dd>
  <dt>
    {{domxref("window.scrollX","window.pageXOffset")}}</dt>
  <dd>
    An alias for {{domxref("window.scrollX")}}.</dd>
  <dt>
    {{domxref("window.scrollY","window.pageYOffset")}}</dt>
  <dd>
    An alias for {{domxref("window.scrollY")}}</dd>
  <dt>
    {{domxref("window.parent")}}</dt>
  <dd>
    Returns a reference to the parent of the current window or subframe.</dd>
  <dt>
    {{domxref("window.performance")}}</dt>
  <dd>
    Provides a hosting area for <a href="/en-US/docs/Navigation_timing" title="Navigation_timing">performance related</a> attributes.</dd>
  <dt>
    {{domxref("window.personalbar")}}</dt>
  <dd>
    Returns the personalbar object, whose visibility can be toggled in the window.</dd>
  <dt>
    {{domxref("window.pkcs11")}} {{obsolete_inline}}</dt>
  <dd>
    Formerly provided access to install and remove PKCS11 modules. Now this property is always null.</dd>
  <dt>
    <code>window.returnValue </code>{{Fx_minversion_inline(3)}}</dt>
  <dd>
    The return value to be returned to the function that called <code>{{domxref("window.showModalDialog()")}}</code> to display the window as a modal dialog.</dd>
  <dt>
    {{domxref("window.screen")}}</dt>
  <dd>
    Returns a reference to the screen object associated with the window.</dd>
  <!-- The following is duplicated on DOM:window.screen -->
  <dt>
    {{domxref("window.screen.availTop")}}</dt>
  <dd>
    Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.</dd>
  <dt>
    {{domxref("window.screen.availLeft")}}</dt>
  <dd>
    Returns the first available pixel available from the left side of the screen.</dd>
  <dt>
    {{domxref("window.screen.availHeight")}}</dt>
  <dd>
    Specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows.</dd>
  <dt>
    {{domxref("window.screen.availWidth")}}</dt>
  <dd>
    Returns the amount of horizontal space in pixels available to the window.</dd>
  <dt>
    {{domxref("window.screen.colorDepth")}}</dt>
  <dd>
    Returns the color depth of the screen.</dd>
  <dt>
    {{domxref("window.screen.height")}}</dt>
  <dd>
    Returns the height of the screen in pixels.</dd>
  <dt>
    {{domxref("window.screen.left")}}</dt>
  <dd>
    Returns the current distance in pixels from the left side of the screen.</dd>
  <dt>
    {{domxref("window.screen.pixelDepth")}}</dt>
  <dd>
    Gets the bit depth of the screen.</dd>
  <dt>
    {{domxref("window.screen.top")}}</dt>
  <dd>
    Returns the distance from the top of the screen.</dd>
  <dt>
    {{domxref("window.screen.width")}}</dt>
  <dd>
    Returns the width of the screen.</dd>
  <!-- end of duplicated content -->
  <dt>
    {{domxref("window.screenX")}}</dt>
  <dd>
    Returns the horizontal distance of the left border of the user's browser from the left side of the screen.</dd>
  <dt>
    {{domxref("window.screenY")}}</dt>
  <dd>
    Returns the vertical distance of the top border of the user's browser from the top side of the screen.</dd>
  <dt>
    {{domxref("window.scrollbars")}}</dt>
  <dd>
    Returns the scrollbars object, whose visibility can be toggled in the window.</dd>
  <dt>
    {{domxref("window.scrollMaxX")}}</dt>
  <dd>
    The maximum offset that the window can be scrolled to horizontally.</dd>
  <dd>
    (i.e., the document width minus the viewport width)</dd>
  <dt>
    {{domxref("window.scrollMaxY")}}</dt>
  <dd>
    The maximum offset that the window can be scrolled to vertically (i.e., the document height minus the viewport height).</dd>
  <dt>
    {{domxref("window.scrollX")}}</dt>
  <dd>
    Returns the number of pixels that the document has already been scrolled horizontally.</dd>
  <dt>
    {{domxref("window.scrollY")}}</dt>
  <dd>
    Returns the number of pixels that the document has already been scrolled vertically.</dd>
  <dt>
    {{domxref("window.self")}}</dt>
  <dd>
    Returns an object reference to the window object itself.</dd>
  <dt>
    {{domxref("Storage#sessionStorage","window.sessionStorage")}} {{Fx_minversion_inline("2.0")}}</dt>
  <dd>
    A storage object for storing data within a single page session.</dd>
  <dt>
    {{domxref("window.sidebar")}}</dt>
  <dd>
    Returns a reference to the window object of the sidebar.</dd>
  <dt>
    {{domxref("window.status")}}</dt>
  <dd>
    Gets/sets the text in the statusbar at the bottom of the browser.</dd>
  <dt>
    {{domxref("window.statusbar")}}</dt>
  <dd>
    Returns the statusbar object, whose visibility can be toggled in the window.</dd>
  <dt>
    {{domxref("window.toolbar")}}</dt>
  <dd>
    Returns the toolbar object, whose visibility can be toggled in the window.</dd>
  <dt>
    {{domxref("window.top")}}</dt>
  <dd>
    Returns a reference to the topmost window in the window hierarchy. This property is read only.</dd>
  <dt>
    {{domxref("window.URL")}} {{gecko_minversion_inline("2.0")}}</dt>
  <dd>
    A DOM URL object, which provides the {{domxref("window.URL.createObjectURL()")}} and {{domxref("window.URL.revokeObjectURL()")}} methods.</dd>
  <dt>
    {{domxref("window.window")}}</dt>
  <dd>
    Returns a reference to the current window.</dd>
  <dt>
    <code>window[0]</code>,<code> window[1]</code>, etc.</dt>
  <dd>
    Returns a reference to the <code>window</code> object in the frames. See {{domxref("window.frames")}} for more details.</dd>
</dl>
<h2 id="Methods">Methods</h2>
<dl>
  <dt>
    {{domxref("element.addEventListener","window.addEventListener")}}</dt>
  <dd>
    Register an event handler to a specific event type on the window.</dd>
  <dt>
    {{domxref("window.alert")}}</dt>
  <dd>
    Displays an alert dialog.</dd>
  <!-- base64 func <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=287112" rel="freelink">https://bugzilla.mozilla.org/show_bug.cgi?id=287112</a> (see last comments) <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=123003" rel="freelink">https://bugzilla.mozilla.org/show_bug.cgi?id=123003</a> <a href="http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsGlobalWindow.cpp#4946" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...indow.cpp#4946</a> -->
  <dt>
    {{domxref("window.atob")}}</dt>
  <dd>
    Decodes a string of data which has been encoded using base-64 encoding.</dd>
  <dt>
    {{domxref("window.back")}}</dt>
  <dd>
    Moves back one in the window history.</dd>
  <dt>
    {{domxref("window.blur")}}</dt>
  <dd>
    Sets focus away from the window.</dd>
  <dt>
    {{domxref("window.btoa")}}</dt>
  <dd>
    Creates a base-64 encoded ASCII string from a string of binary data.</dd>
  <dt>
    {{domxref("window.captureEvents")}} {{Obsolete_inline(24)}}</dt>
  <dd>
    Registers the window to capture all events of the specified type.</dd>
  <dt>
    {{domxref("window.clearImmediate")}}</dt>
  <dd>
    Cancels the repeated execution set using <code>setImmediate</code>.</dd>
  <dt>
    {{domxref("window.clearInterval")}}</dt>
  <dd>
    Cancels the repeated execution set using <code>setInterval</code>.</dd>
  <dt>
    {{domxref("window.clearTimeout")}}</dt>
  <dd>
    Cancels the repeated execution set using <code>setTimeout</code>.</dd>
  <dt>
    {{domxref("window.close")}}</dt>
  <dd>
    Closes the current window.</dd>
  <dt>
    {{domxref("window.confirm")}}</dt>
  <dd>
    Displays a dialog with a message that the user needs to respond to.</dd>
  <dt>
    {{domxref("window.disableExternalCapture")}} {{Obsolete_inline(24)}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.dispatchEvent")}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.dump")}}</dt>
  <dd>
    Writes a message to the console.</dd>
  <dt>
    {{domxref("window.enableExternalCapture")}} {{Obsolete_inline(24)}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.escape")}}</dt>
  <dd>
    Encodes a string.</dd>
  <dt>
    {{domxref("window.find")}}</dt>
  <dd>
    Searches for a given string in a window.</dd>
  <dt>
    {{domxref("window.focus")}}</dt>
  <dd>
    Sets focus on the current window.</dd>
  <dt>
    {{domxref("window.forward")}}</dt>
  <dd>
    Moves the window one document forward in the history.</dd>
  <dt>
    {{domxref("window.GeckoActiveXObject")}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.getAttention")}}</dt>
  <dd>
    Flashes the application icon.</dd>
  <dt>
    {{domxref("window.getAttentionWithCycleCount")}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.getComputedStyle")}}</dt>
  <dd>
    Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element.</dd>
  <dt>
    {{domxref("window.getDefaulComputedStyle")}}</dt>
  <dd>
    Gets default computed style for the specified element, ignoring author stylesheets.</dd>
  <dt>
    {{domxref("window.getSelection")}}</dt>
  <dd>
    Returns the selection object representing the selected item(s).</dd>
  <dt>
    {{domxref("window.home")}}</dt>
  <dd>
    Returns the browser to the home page.</dd>
  <dt>
    {{domxref("window.matchMedia")}} {{gecko_minversion_inline("6.0")}}</dt>
  <dd>
    Returns a {{domxref("MediaQueryList")}} object representing the specified media query string.</dd>
  <dt>
    {{domxref("window.maximize")}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.minimize")}} (top-level XUL windows only)</dt>
  <dd>
    Minimizes the window.</dd>
  <dt>
    {{domxref("window.moveBy")}}</dt>
  <dd>
    Moves the current window by a specified amount.</dd>
  <dt>
    {{domxref("window.moveTo")}}</dt>
  <dd>
    Moves the window to the specified coordinates.</dd>
  <dt>
    {{domxref("window.mozRequestAnimationFrame")}} {{gecko_minversion_inline("2.0")}}</dt>
  <dd>
    Tells the browser that an animation is in progress, requesting that the browser schedule a repaint of the window for the next animation frame. This will cause a <code>MozBeforePaint</code> event to fire before that repaint occurs.</dd>
  <dt>
    {{domxref("window.open")}}</dt>
  <dd>
    Opens a new window.</dd>
  <dt>
    {{domxref("window.openDialog")}}</dt>
  <dd>
    Opens a new dialog window.</dd>
  <dt>
    {{domxref("window.postMessage")}} {{Fx_minversion_inline(3)}}</dt>
  <dd>
    Provides a secure means for one window to send a string of data to another window, which need not be within the same domain as the first, in a secure manner.</dd>
  <dt>
    {{domxref("window.print")}}</dt>
  <dd>
    Opens the Print Dialog to print the current document.</dd>
  <dt>
    {{domxref("window.prompt")}}</dt>
  <dd>
    Returns the text entered by the user in a prompt dialog.</dd>
  <dt>
    {{domxref("window.QueryInterface")}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.releaseEvents")}} {{Obsolete_inline(24)}}</dt>
  <dd>
    Releases the window from trapping events of a specific type.</dd>
  <dt>
    {{domxref("element.removeEventListener","window.removeEventListener")}}</dt>
  <dd>
    Removes an event listener from the window.</dd>
  <dt>
    {{domxref("window.resizeBy")}}</dt>
  <dd>
    Resizes the current window by a certain amount.</dd>
  <dt>
    {{domxref("window.resizeTo")}}</dt>
  <dd>
    Dynamically resizes window.</dd>
  <dt>
    {{domxref("window.restore")}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.routeEvent")}} {{Obsolete_inline(24)}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.scroll")}}</dt>
  <dd>
    Scrolls the window to a particular place in the document.</dd>
  <dt>
    {{domxref("window.scrollBy")}}</dt>
  <dd>
    Scrolls the document in the window by the given amount.</dd>
  <dt>
    {{domxref("window.scrollByLines")}}</dt>
  <dd>
    Scrolls the document by the given number of lines.</dd>
  <dt>
    {{domxref("window.scrollByPages")}}</dt>
  <dd>
    Scrolls the current document by the specified number of pages.</dd>
  <dt>
    {{domxref("window.scrollTo")}}</dt>
  <dd>
    Scrolls to a particular set of coordinates in the document.</dd>
  <dt>
    {{domxref("window.setCursor")}}</dt>
  <dd>
    Changes the cursor for the current window</dd>
  <dt>
    {{domxref("window.setImmediate")}}</dt>
  <dd>
    Execute a function after the browser has finished other heavy tasks</dd>
  <dt>
    {{domxref("window.setInterval")}}</dt>
  <dd>
    Execute a function each X milliseconds.</dd>
  <dt>
    {{domxref("window.setResizable")}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.setTimeout")}}</dt>
  <dd>
    Sets a delay for executing a function.</dd>
  <dt>
    {{domxref("window.showModalDialog")}} {{Fx_minversion_inline(3)}}</dt>
  <dd>
    Displays a modal dialog.</dd>
  <dt>
    {{domxref("window.sizeToContent")}}</dt>
  <dd>
    Sizes the window according to its content.</dd>
  <dt>
    {{domxref("window.stop")}}</dt>
  <dd>
    This method stops window loading.</dd>
  <dt>
    {{domxref("window.unescape")}}</dt>
  <dd>
    Unencodes a value that has been encoded in hexadecimal (e.g. a cookie).</dd>
  <dt>
    {{domxref("window.updateCommands")}}</dt>
  <dd>
    Updates the state of commands of the current chrome window (UI).</dd>
  <dt>
    {{domxref("window.XPCNativeWrapper")}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.XPCSafeJSObjectWrapper")}}</dt>
</dl>
<h2 id="Event_handlers">Event handlers</h2>
<p>These are properties of the window object that can be set to establish event handlers for the various things that can happen in the window that might be of interest.</p>
<div class="geckoVersionNote" style="undefined">
  <p>{{gecko_callout_heading("9.0")}}</p>
  <p>Starting in Gecko 9.0 {{geckoRelease("9.0")}}, you can now use the syntax <code>if ("onabort" in window)</code> to determine whether or not a given event handler property exists. This is because event handler interfaces have been updated to be proper web IDL interfaces. See <a href="/en-US/docs/DOM/DOM_event_handlers" title="DOM/DOM event handlers">DOM event handlers</a> for details.</p>
</div>
<dl>
  <dt>
    {{domxref("window.onabort")}}</dt>
  <dd>
    An event handler property for abort events on the window.</dd>
  <dt>
    {{domxref("window.onbeforeunload")}}</dt>
  <dd>
    An event handler property for before-unload events on the window.</dd>
  <dt>
    {{domxref("window.onblur")}}</dt>
  <dd>
    An event handler property for blur events on the window.</dd>
  <dt>
    {{domxref("window.onchange")}}</dt>
  <dd>
    An event handler property for change events on the window.</dd>
  <dt>
    {{domxref("window.onclick")}}</dt>
  <dd>
    An event handler property for click events on the window.</dd>
  <dt>
    {{domxref("window.onclose")}}</dt>
  <dd>
    An event handler property for handling the window close event.</dd>
  <dt>
    {{domxref("window.oncontextmenu")}}</dt>
  <dd>
    An event handler property for right-click events on the window.</dd>
  <dt>
    {{domxref("window.ondevicelight")}}</dt>
  <dd>
    An event handler property for any ambient light levels changes</dd>
  <dt>
    {{domxref("window.ondevicemotion")}} {{gecko_minversion_inline("6.0")}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.ondeviceorientation")}} {{gecko_minversion_inline("6.0")}}</dt>
  <dd>
    {{todo("NeedsContents")}}</dd>
  <dt>
    {{domxref("window.ondeviceproximity")}}</dt>
  <dd>
    An event handler property for device proximity event</dd>
  <dt>
    {{domxref("window.ondragdrop")}}</dt>
  <dd>
    An event handler property for drag and drop events on the window.</dd>
  <dt>
    {{domxref("window.onerror")}}</dt>
  <dd>
    An event handler property for errors raised on the window.</dd>
  <dt>
    {{domxref("window.onfocus")}}</dt>
  <dd>
    An event handler property for focus events on the window.</dd>
  <dt>
    {{domxref("window.onhashchange")}} {{gecko_minversion_inline("1.9.2")}}</dt>
  <dd>
    An event handler property for hash change events on the window; called when the part of the URL after the hash mark ("#") changes.</dd>
  <dt>
    {{domxref("window.onkeydown")}}</dt>
  <dd>
    An event handler property for keydown events on the window.</dd>
  <dt>
    {{domxref("window.onkeypress")}}</dt>
  <dd>
    An event handler property for keypress events on the window.</dd>
  <dt>
    {{domxref("window.onkeyup")}}</dt>
  <dd>
    An event handler property for keyup events on the window.</dd>
  <dt>
    {{domxref("window.onload")}}</dt>
  <dd>
    An event handler property for window loading.</dd>
  <dt>
    {{domxref("window.onmousedown")}}</dt>
  <dd>
    An event handler property for mousedown events on the window.</dd>
  <dt>
    {{domxref("window.onmousemove")}}</dt>
  <dd>
    An event handler property for mousemove events on the window.</dd>
  <dt>
    {{domxref("window.onmouseout")}}</dt>
  <dd>
    An event handler property for mouseout events on the window.</dd>
  <dt>
    {{domxref("window.onmouseover")}}</dt>
  <dd>
    An event handler property for mouseover events on the window.</dd>
  <dt>
    {{domxref("window.onmouseup")}}</dt>
  <dd>
    An event handler property for mouseup events on the window.</dd>
  <dt>
    {{domxref("window.onmozbeforepaint")}} {{gecko_minversion_inline("2.0")}}</dt>
  <dd>
    An event handler property for the <code>MozBeforePaint</code> event, which is sent before repainting the window if the event has been requested by a call to the {{domxref("window.mozRequestAnimationFrame()")}} method.</dd>
  <dt>
    {{domxref("window.onpaint")}}</dt>
  <dd>
    An event handler property for paint events on the window.</dd>
  <dt>
    {{domxref("window.onpopstate")}} {{gecko_minversion_inline("2.0")}}</dt>
  <dd>
    An event handler property for popstate events, which are fired when navigating to a session history entry representing a state object.</dd>
  <dt>
    {{domxref("window.onreset")}}</dt>
  <dd>
    An event handler property for reset events on the window.</dd>
  <dt>
    {{domxref("window.onresize")}}</dt>
  <dd>
    An event handler property for window resizing.</dd>
  <dt>
    {{domxref("window.onscroll")}}</dt>
  <dd>
    An event handler property for window scrolling.</dd>
  <dt>
    {{domxref("window.onselect")}}</dt>
  <dd>
    An event handler property for window selection.</dd>
  <dt>
    {{domxref("window.onsubmit")}}</dt>
  <dd>
    An event handler property for submits on window forms.</dd>
  <dt>
    {{domxref("window.onunload")}}</dt>
  <dd>
    An event handler property for unload events on the window.</dd>
  <dt>
    {{domxref("window.onuserproximity")}}</dt>
  <dd>
    An event handler property for user proximity events</dd>
  <dt>
    {{domxref("window.onpageshow")}}</dt>
  <dd>
    An event handler property for pageshow events on the window.</dd>
  <dt>
    {{domxref("window.onpagehide")}}</dt>
  <dd>
    An event handler property for pagehide events on the window.</dd>
</dl>
<h2 id="Constructors">Constructors</h2>
<dl>
  <dt>
    {{domxref("Image")}}</dt>
  <dd>
    Used for creating an {{domxref("HTMLImageElement")}}.</dd>
  <dt>
    {{domxref("Option")}}</dt>
  <dd>
    Used for creating an {{domxref("HTMLOptionElement")}}</dd>
  <dt>
    {{domxref("Worker")}}</dt>
  <dd>
    Used for creating a <a href="/en-US/docs/DOM/Using_web_workers" title="Using_web_workers">Web worker</a></dd>
  <dt>
    &nbsp;</dt>
</dl>
<h2 id="See_also">See also</h2>
<ul>
  <li><a href="/en-US/docs/Working_with_windows_in_chrome_code" title="working_with_windows_in_chrome_code">Working with windows in chrome code</a></li>
</ul>
Revert to this revision