Table of contents
- 1.1. Properties
- 1.2. Methods
- 1.3. Event Handlers
- 2. See also
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
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
window.resizeTo and
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
-
window.applicationCacheRequires Gecko 1.9 - An
nsIDOMOfflineResourceListobject providing access to the offline resources for the window. -
window.closed - 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.
-
window.contentand window._content - Returns a reference to the content element in the current window. The variant with underscore is deprecated.
-
window.controllers - Returns the XUL controller objects for the current chrome window.
-
window.crypto - Returns the browser crypto object.
-
window.defaultStatus - Gets/sets the status bar text for the given window.
-
window.dialogArgumentsNew in Firefox 3 - Gets the arguments passed to the window (if it's a dialog box) at the time
was called. This is anwindow.showModalDialog()nsIArray. -
window.directoriesObsolete - Synonym of
window.personalbar -
window.document - Returns a reference to the document that the window contains.
-
window.frameElement - Returns the element in which the window is embedded, or null if the window is not embedded.
-
window.frames - Returns an array of the subframes in the current window.
-
window.fullScreenRequires Gecko 1.9 - This property indicates whether the window is displayed in full screen or not.
-
window.globalStorageRequires Gecko 1.8.1 Non-standard - Multiple storage objects that are used for storing data across multiple pages. Note that this is non-standard; it is recommended that you use window.localStorage instead.
-
window.history - Returns a reference to the history object.
-
window.innerHeight - Gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar.
-
window.innerWidth - Gets the width of the content area of the browser window including, if rendered, the vertical scrollbar.
-
window.length - Returns the number of frames in the window. See also
window.frames. -
window.location - Gets/sets the location, or current URL, of the window object.
-
window.locationbar - Returns the locationbar object, whose visibility can be toggled in the window.
- window.localStorage Requires Gecko 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.
-
window.menubar - Returns the menubar object, whose visibility can be toggled in the window.
-
window.messageManagerRequires Gecko 2.0 - Returns the message manager object for this window.
-
window.mozAnimationStartTimeRequires Gecko 2.0 - The time in milliseconds since epoch at which the current animation cycle began.
-
window.mozInnerScreenXRequires Gecko 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
mozScreenPixelsPerCSSPixelinnsIDOMWindowUtilsfor a conversion factor to adapt to screen pixels if needed. -
window.mozInnerScreenYRequires Gecko 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
mozScreenPixelsPerCSSPixelfor a conversion factor to adapt to screen pixels if needed. -
window.mozPaintCountRequires Gecko 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.
-
window.name - Gets/sets the name of the window.
-
window.navigator - Returns a reference to the navigator object.
-
window.opener - Returns a reference to the window that opened this current window.
-
window.outerHeight - Gets the height of the outside of the browser window.
-
window.outerWidth - Gets the width of the outside of the browser window.
- window.pageXOffset
- An alias for
window.scrollX. - window.pageYOffset
- An alias for
window.scrollY -
window.parent - Returns a reference to the parent of the current window or subframe.
-
window.personalbar - Returns the personalbar object, whose visibility can be toggled in the window.
-
window.pkcs11Obsolete - Formerly provided access to install and remove PKCS11 modules. Now this property is always null.
-
window.returnValueNew in Firefox 3 - The return value to be returned to the function that called
to display the window as a modal dialog.window.showModalDialog() -
window.screen - Returns a reference to the screen object associated with the window.
-
window.screen.availTop - Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
-
window.screen.availLeft - Returns the first available pixel available from the left side of the screen.
-
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.
-
window.screen.availWidth - Returns the amount of horizontal space in pixels available to the window.
-
window.screen.colorDepth - Returns the color depth of the screen.
-
window.screen.height - Returns the height of the screen in pixels.
-
window.screen.left - Returns the current distance in pixels from the left side of the screen.
-
window.screen.pixelDepth - Gets the bit depth of the screen.
-
window.screen.top - Returns the distance from the top of the screen.
-
window.screen.width - Returns the width of the screen.
-
window.screenX - Returns the horizontal distance of the left border of the user's browser from the left side of the screen.
-
window.screenY - Returns the vertical distance of the top border of the user's browser from the top side of the screen.
-
window.scrollbars - Returns the scrollbars object, whose visibility can be toggled in the window.
-
window.scrollMaxX - The maximum offset that the window can be scrolled to horizontally.
- (i.e., the document width minus the viewport width)
-
window.scrollMaxY - The maximum offset that the window can be scrolled to vertically (i.e., the document height minus the viewport height).
-
window.scrollX - Returns the number of pixels that the document has already been scrolled horizontally.
-
window.scrollY - Returns the number of pixels that the document has already been scrolled vertically.
-
window.self - Returns an object reference to the window object itself.
- window.sessionStorage New in Firefox 2.0
- A storage object for storing data within a single page session.
-
window.sidebar - Returns a reference to the window object of the sidebar.
-
window.status - Gets/sets the text in the statusbar at the bottom of the browser.
-
window.statusbar - Returns the statusbar object, whose visibility can be toggled in the window.
-
window.toolbar - Returns the toolbar object, whose visibility can be toggled in the window.
-
window.top - Returns a reference to the topmost window in the window hierarchy. This property is read only.
-
window.URLRequires Gecko 2.0 - A DOM URL object, which provides the
window.URL.createObjectURL()andwindow.URL.revokeObjectURL()methods. -
window.window - Returns a reference to the current window.
- window[0], window[1], etc.
- Returns a reference to the
windowobject in the frames. Seewindow.framesfor more details.
Attachments (0)
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |