window

Javascript has the global object. In browser environment, this is the window object. All global variables become properties of the window object.

window.somevar = 1;

All the core javascript functions are methods of the window object.

window.parseInt(123a456);
Note
The window object also provide data about the browser environment. There's a window object for every frame, iframe, popup, or browser tab.
PropertyDescription
closedReturns a Boolean value indicating whether a window has been closed or not
defaultStatusSets or returns the default text in the statusbar of a window
documentReturns the Document object for the window
frameElementReturns the <iframe> element in which the current window is inserted
framesReturns all <iframe> elements in the current window
historyReturns the History object for the window
innerHeightReturns the inner height of a window's content area
innerWidthReturns the inner width of a window's content area
lengthReturns the number of <iframe> elements in the current window
localStorageReturns a reference to the local storage object used to store data. Stores data with no expiration date
locationReturns the Location object for the window
nameSets or returns the name of a window
navigatorReturns the Navigator object for the window
openerReturns a reference to the window that created the window
outerHeightReturns the outer height of a window, including toolbars/scrollbars
outerWidthReturns the outer width of a window, including toolbars/scrollbars
pageXOffsetReturns the pixels the current document has been scrolled (horizontally) from the upper left corner of the window
pageYOffsetReturns the pixels the current document has been scrolled (vertically) from the upper left corner of the window
parentReturns the parent window of the current window
screenReturns the Screen object for the window
screenLeftReturns the horizontal coordinate of the window relative to the screen
screenTopReturns the vertical coordinate of the window relative to the screen
screenXReturns the horizontal coordinate of the window relative to the screen
screenYReturns the vertical coordinate of the window relative to the screen
sessionStorageReturns a reference to the local storage object used to store data. Stores data for one session (lost when the browser tab is closed)
scrollXAn alias of pageXOffset
scrollYAn alias of pageYOffset
selfReturns the current window
statusSets or returns the text in the statusbar of a window
topReturns the topmost browser window
Window Object Methods
MethodDescription
alert()Displays an alert box with a message and an OK button
atob()Decodes a base-64 encoded string
blur()Removes focus from the current window
btoa()Encodes a string in base-64
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
focus()Sets focus to the current window
getComputedStyle()Gets the current computed CSS styles applied to an element
getSelection()Returns a Selection object representing the range of text selected by the user
matchMedia()Returns a MediaQueryList object representing the specified CSS media query string
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
resizeTo()Resizes the window to the specified width and height
scroll()Deprecated. This method has been replaced by the scrollTo() method.
scrollBy()Scrolls the document by the specified number of pixels
scrollTo()Scrolls the document 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
stop()Stops the window from loading
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +