Did you find this useful?
Socialize it today.


JavaScript Window Object

Monday, May 07, 2012

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. Here is a summary.

Window Object Properties



PropertyDescription
closedGets a Boolean value indicating whether a window has been closed or not
defaultStatusSets or returns the default text in the statusbar of a window. Only Opera.
documentGets the Document object for the window
framesGets an array of all the frames in the current window
historyGets the History object for the window
innerHeightSets or gets the inner height of a window's content area
innerWidthSets or gets the inner width of a window's content area
lengthGets the number of frames in a window
locationGets the Location object for the window
nameSets or gets the name of a window
navigatorGets the Navigator object for the window
openerGets a reference to the window that created the window
outerHeightSets or gets the outer height of a window, including toolbars and scrollbars
outerWidthSets or gets the outer width of a window, including toolbars and scrollbars
pageXOffsetGets the pixels the current document has been scrolled horizontally from the upper left corner. No IE.
pageYOffsetGets the pixels the current document has been scrolled vertically from the upper left corner. No IE.
parentGets the parent window of the current window
screenGets the Screen object for the window
screenLeftGets the x coordinate of the window relative to the screen. No Firefox.
screenTopGets the y coordinate of the window relative to the screen. No Firefox.
screenXGets the x coordinate of the window relative to the screen. No IE.
screenYGets the y coordinate of the window relative to the screen. No IE.
selfGets the current window
statusSets the text in the statusbar of a window. Only Opera.
topGets the top most browser window


Window Object Methods



MethodDescription
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


We will be covering some of the Window Object properties and methods in more detail in the upcoming articles.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

JavaScript and jQuery: The Missing Manual Murachs JavaScript and DOM Scripting HTML CSS and JavaScript Editor