The JavaScript Window object represents an open window in a browser. While there is no standard that applies to the Window object, all major browsers support it so it is safe to use in your web projects. There are many useful properties and methods that can be used in your JavaScript projects.
Window Object Properties
Property | Description |
---|---|
closed | Gets a Boolean value indicating whether a window has been closed or not. |
defaultStatus | Sets or returns the default text in the status bar of a window. Only Opera. |
document | Gets the Document object for the window. |
frames | Gets an array of all the frames in the current window. |
history | Gets the History object for the window. |
innerHeight | Sets or gets the inner height of a window’s content area. |
innerWidth | Sets or gets the inner width of a window’s content area. |
length | Gets the number of frames in a window. |
location | Gets the Location object for the window. |
name | Sets or gets the name of a window. |
navigator | Gets the Navigator object for the window. |
opener | Gets a reference to the window that created the window. |
outerHeight | Sets or gets the outer height of a window, including toolbars and scrollbars. |
outerWidth | Sets or gets the outer width of a window, including toolbars and scrollbars |
pageXOffset | Gets the pixels the current document has been scrolled horizontally from the upper left corner. No IE. |
pageYOffset | Gets the pixels the current document has been scrolled vertically from the upper left corner. No IE. |
parent | Gets the parent window of the current window. |
screen | Gets the Screen object for the window. |
screenLeft | Gets the x coordinate of the window relative to the screen. No Firefox. |
screenTop | Gets the y coordinate of the window relative to the screen. No Firefox. |
screenX | Gets the x coordinate of the window relative to the screen. No IE. |
screenY | Gets the y coordinate of the window relative to the screen. No IE. |
self | Gets the current window. |
status | Sets the text in the status bar of a window. Only Opera. |
top | Gets the top most browser window. |
Window Object Methods
Method | Description |
---|---|
alert() | Displays an alert with a message and an OK button. |
blur() | Removes focus from the current window. No Opera. No Chrome. |
clearInterval() | Clears a timer set with setInterval() . |
clearTimeout() | Clears a timer set with setTimeout() . |
close() | Closes the current window. |
confirm() | Displays a dialog box with a message and an OK and a Cancel button. |
createPopup() | Creates a pop-up window. IE only. |
focus() | Sets focus to the current window. |
moveBy() | Moves a window relative to its current position. |
moveTo() | Moves a window to the specified position. |
open() | Opens a new browser window. |
print() | Prints the content of the current window. |
prompt() | Displays a dialog box that prompts the visitor for input. |
resizeBy() | Resizes the window by the specified pixels. No Opera. No Chrome. |
resizeTo() | Resizes the window to the specified width and height. |
scrollBy() | Scrolls the content by the specified number of pixels. |
scrollTo() | Scrolls the content to the specified coordinates. |
setInterval() | Calls a function or evaluates an expression at specified intervals (in milliseconds). |
setTimeout() | Calls a function or evaluates an expression after a specified number of milliseconds. |