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
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
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
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.
nsIDOMOfflineResourceListobject providing access to the offline resources for the window.
- This property indicates whether the current window is closed or not.
- The entry point to many XPCOM features. Some properties, e.g. classes, are only available to sufficiently privileged code.
- Returns a reference to the console object providing access to the browser's debugging console.
- Returns a reference to the content element in the current window. The variant with underscore is deprecated.
- Returns the XUL controller objects for the current chrome window.
- Returns the browser crypto object.
- Gets/sets the status bar text for the given window.
- Gets the arguments passed to the window (if it's a dialog box) at the time
was called. This is an
- Synonym of
- Returns a reference to the document that the window contains.
- Returns the element in which the window is embedded, or null if the window is not embedded.
- Returns an array of the subframes in the current window.
- This property indicates whether the window is displayed in full screen or not.
- Unsupported since Gecko 13 (Firefox 13). Use
Was: Multiple storage objects that are used for storing data across multiple pages.
- Returns a reference to the history object.
- Gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar.
- Gets the width of the content area of the browser window including, if rendered, the vertical scrollbar.
- Returns the number of frames in the window. See also
- Gets/sets the location, or current URL, of the window object.
- Returns the locationbar object, whose visibility can be toggled in the window.
- Returns a reference to the local storage object used to store data that may only be accessed by the origin that created it.
- Returns the menubar object, whose visibility can be toggled in the window.
- Returns the message manager object for this window.
- The time in milliseconds since epoch at which the current animation cycle began.
- 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
nsIDOMWindowUtilsfor a conversion factor to adapt to screen pixels if needed.
- 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
mozScreenPixelsPerCSSPixelfor a conversion factor to adapt to screen pixels if needed.
- 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.
- Gets/sets the name of the window.
- Returns a reference to the navigator object.
- Returns a reference to the window that opened this current window.
- Gets the height of the outside of the browser window.
- Gets the width of the outside of the browser window.
- An alias for
- An alias for
- Returns a reference to the parent of the current window or subframe.
- Provides a hosting area for performance related attributes.
- Returns the personalbar object, whose visibility can be toggled in the window.
- Formerly provided access to install and remove PKCS11 modules. Now this property is always null.
- The return value to be returned to the function that called
to display the window as a modal dialog.
- Returns a reference to the screen object associated with the window.
- Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
- Returns the first available pixel available from the left side of the screen.
- 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.
- Returns the amount of horizontal space in pixels available to the window.
- Returns the color depth of the screen.
- Returns the height of the screen in pixels.
- Returns the current distance in pixels from the left side of the screen.
- Gets the bit depth of the screen.
- Returns the distance from the top of the screen.
- Returns the width of the screen.
- Returns the horizontal distance of the left border of the user's browser from the left side of the screen.
- Returns the vertical distance of the top border of the user's browser from the top side of the screen.
- Returns the scrollbars object, whose visibility can be toggled in the window.
- The maximum offset that the window can be scrolled to horizontally.
- (i.e., the document width minus the viewport width)
- The maximum offset that the window can be scrolled to vertically (i.e., the document height minus the viewport height).
- Returns the number of pixels that the document has already been scrolled horizontally.
- Returns the number of pixels that the document has already been scrolled vertically.
- Returns an object reference to the window object itself.
- A storage object for storing data within a single page session.
- Returns a reference to the window object of the sidebar.
- Gets/sets the text in the statusbar at the bottom of the browser.
- Returns the statusbar object, whose visibility can be toggled in the window.
- Returns the toolbar object, whose visibility can be toggled in the window.
- Returns a reference to the topmost window in the window hierarchy. This property is read only.
- A DOM URL object, which provides the
- Returns a reference to the current window.
- Returns a reference to the
windowobject in the frames. See
window.framesfor more details.
- Register an event handler to a specific event type on the window.
- Displays an alert dialog.
- Decodes a string of data which has been encoded using base-64 encoding.
- Moves back one in the window history.
- Sets focus away from the window.
- Creates a base-64 encoded ASCII string from a string of binary data.
- Registers the window to capture all events of the specified type.
- Cancels the repeated execution set using
- Cancels the repeated execution set using
- Cancels the repeated execution set using
- Closes the current window.
- Displays a dialog with a message that the user needs to respond to.
- Writes a message to the console.
- Encodes a string.
- Searches for a given string in a window.
- Sets focus on the current window.
- Moves the window one document forward in the history.
- Flashes the application icon.
- Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element.
- Returns the selection object representing the selected item(s).
- Returns the browser to the home page.
- Returns a
MediaQueryListobject representing the specified media query string.
window.minimize(top-level XUL windows only)
- Minimizes the window.
- Moves the current window by a specified amount.
- Moves the window to the specified coordinates.
- 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
MozBeforePaintevent to fire before that repaint occurs.
- Opens a new window.
- Opens a new dialog window.
- 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.
- Opens the Print Dialog to print the current document.
- Returns the text entered by the user in a prompt dialog.
- Releases the window from trapping events of a specific type.
- Removes an event listener from the window.
- Resizes the current window by a certain amount.
- Dynamically resizes window.
- Scrolls the window to a particular place in the document.
- Scrolls the document in the window by the given amount.
- Scrolls the document by the given number of lines.
- Scrolls the current document by the specified number of pages.
- Scrolls to a particular set of coordinates in the document.
- Changes the cursor for the current window
- Execute a function after the browser has finished other heavy tasks
- Execute a function each X milliseconds.
- Sets a delay for executing a function.
- Displays a modal dialog.
- Sizes the window according to its content.
- This method stops window loading.
- Unencodes a value that has been encoded in hexadecimal (e.g. a cookie).
- Updates the state of commands of the current chrome window (UI).
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.
Starting in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6)
, 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.
- An event handler property for abort events on the window.
- An event handler property for before-unload events on the window.
- An event handler property for blur events on the window.
- An event handler property for change events on the window.
- An event handler property for click events on the window.
- An event handler property for handling the window close event.
- An event handler property for right-click events on the window.
- An event handler property for drag and drop events on the window.
- An event handler property for errors raised on the window.
- An event handler property for focus events on the window.
- An event handler property for hash change events on the window; called when the part of the URL after the hash mark ("#") changes.
- An event handler property for keydown events on the window.
- An event handler property for keypress events on the window.
- An event handler property for keyup events on the window.
- An event handler property for window loading.
- An event handler property for mousedown events on the window.
- An event handler property for mousemove events on the window.
- An event handler property for mouseout events on the window.
- An event handler property for mouseover events on the window.
- An event handler property for mouseup events on the window.
- An event handler property for the
MozBeforePaintevent, which is sent before repainting the window if the event has been requested by a call to the
- An event handler property for paint events on the window.
- An event handler property for popstate events, which are fired when navigating to a session history entry representing a state object.
- An event handler property for reset events on the window.
- An event handler property for window resizing.
- An event handler property for window scrolling.
- An event handler property for window selection.
- An event handler property for submits on window forms.
- An event handler property for unload events on the window.
- An event handler property for pageshow events on the window.
- An event handler property for pagehide events on the window.