DOM:window
From MDC
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.
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.
[edit] Properties
- window.applicationCache New in Firefox 3
- 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.content and 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.dialogArguments New in Firefox 3
- Gets the arguments passed to the window (if it's a dialog box) at the time
window.showModalDialog()was called. This is annsIArray.
- window.directories
- Returns a reference to the directories toolbar in the current chrome.
- 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.fullScreen New in Firefox 3
- This property indicates whether the window is displayed in full screen or not.
- window.globalStorage New in Firefox 2
- Multiple storage objects that are used for storing data across multiple pages.
- 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.
- 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.menubar
- Returns the menubar object, whose visibility can be toggled in the window.
- 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.pkcs11
- Returns the pkcs11 object, which can be used to install drivers and other software associated with the pkcs11 protocol.
- window.returnValue New in Firefox 3
- The return value to be returned to the function that called
window.showModalDialog()to display the window as a modal dialog.
- 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
- 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.
- window.window
- Returns a reference to the current window.
[edit] Methods
- window.alert
- Displays an alert dialog.
- window.addEventListener
- Register an event handler to a specific event type on the window.
- window.atob
- Decodes a string of data which has been encoded using base-64 encoding.
- window.back
- Moves back one in the window history.
- window.blur
- Sets focus away from the window.
- window.btoa
- Creates a base-64 encoded ASCII string from a string of binary data.
- window.captureEvents Obsolete
- Registers the window to capture all events of the specified type.
- window.clearInterval
- Cancels the repeated execution set using
setInterval.
- window.clearTimeout
- Clears a delay that's been set for a specific function.
- window.close
- Closes the current window.
- window.confirm
- Displays a dialog with a message that the user needs to respond to.
- window.dump
- Writes a message to the console.
- window.escape
- Encodes a string.
- window.find
- Searches for a given string in a window.
- window.focus
- Sets focus on the current window.
- window.forward
- Moves the window one document forward in the history.
- window.getAttention
- Flashes the application icon.
- window.getComputedStyle
- Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element.
- window.getSelection
- Returns the selection object representing the selected item(s).
- window.home
- Returns the browser to the home page.
- window.moveBy
- Moves the current window by a specified amount.
- window.moveTo
- Moves the window to the specified coordinates.
- window.open
- Opens a new window.
- window.openDialog
- Opens a new dialog window.
- window.postMessage New in Firefox 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.
- window.print
- Opens the Print Dialog to print the current document.
- window.prompt
- Returns the text entered by the user in a prompt dialog.
- window.releaseEvents Obsolete
- Releases the window from trapping events of a specific type.
- window.removeEventListener
- Removes an event listener from the window.
- window.resizeBy
- Resizes the current window by a certain amount.
- window.resizeTo
- Dynamically resizes window.
- window.scroll
- Scrolls the window to a particular place in the document.
- window.scrollBy
- Scrolls the document in the window by the given amount.
- window.scrollByLines
- Scrolls the document by the given number of lines.
- window.scrollByPages
- Scrolls the current document by the specified number of pages.
- window.scrollTo
- Scrolls to a particular set of coordinates in the document.
- window.setInterval
- Execute a function each X milliseconds.
- window.setTimeout
- Sets a delay for executing a function.
- window.showModalDialog New in Firefox 3
- Displays a modal dialog.
- window.sizeToContent
- Sizes the window according to its content.
- window.stop
- This method stops window loading.
- window.unescape
- Unencodes a value that has been encoded in hexadecimal (e.g. a cookie).
- window.updateCommands
- Updates the state of commands of the current chrome window (UI).
[edit] Event Handlers
- window.onabort
- An event handler property for abort events on the window.
- window.onbeforeunload
- An event handler property for before-unload events on the window.
- window.onblur
- An event handler property for blur events on the window.
- window.onchange
- An event handler property for change events on the window.
- window.onclick
- An event handler property for click events on the window.
- window.onclose
- An event handler property for handling the window close event.
- window.oncontextmenu
- An event handler property for right-click events on the window.
- window.ondragdrop
- An event handler property for drag and drop events on the window.
- window.onerror
- An event handler property for errors raised on the window.
- window.onfocus
- An event handler property for focus events on the window.
- window.onkeydown
- An event handler property for keydown events on the window.
- window.onkeypress
- An event handler property for keypress events on the window.
- window.onkeyup
- An event handler property for keyup events on the window.
- window.onload
- An event handler property for window loading.
- window.onmousedown
- An event handler property for mousedown events on the window.
- window.onmousemove
- An event handler property for mousemove events on the window.
- window.onmouseout
- An event handler property for mouseout events on the window.
- window.onmouseover
- An event handler property for mouseover events on the window.
- window.onmouseup
- An event handler property for mouseup events on the window.
- window.onpaint
- An event handler property for paint events on the window.
- window.onreset
- An event handler property for reset events on the window.
- window.onresize
- An event handler property for window resizing.
- window.onscroll
- An event handler property for window scrolling.
- window.onselect
- An event handler property for window selection.
- window.onsubmit
- An event handler property for submits on window forms.
- window.onunload
- An event handler property for unload events on the window.