Window Object
The window interface is supported by all browsers and it is provided by the browser itself. The window object is the property of the browser.
In browser JavaScript, all of the global objects, functions, and variables are automatically the members of this object. The window interface is entitled to present a window that constitutes a complete DOM document. In simple words, a window object represents an open window (tab) in a browser. Even we can access the entire DOM document using the document property. The document.defaultView property can be used to obtain the window for the given document.
In browser JavaScript, the window is a global variable and represents the entire window within which the script is executing. The window object is available within an entire document with the global scope.
If multiple tabs are being used in the browser then each tab has its own window object. However, few properties and methods are still applicable to the overall browser window like resizeTo() and innerHeight().
If a page is containing <iframe> tags, then the browser generates one window object for the overall document and one additional window object per <iframe> tag.
![]() |
Properties
closed
This property indicates whether a window has been closed or notconsole
Return a reference to the Console object. This is used to provide methods for displaying logging information to the browser's consoledocument
This property represents the reference to the Document object for the window.frames
Returns an array of all the <iframe> elements in the current windowhistory
Represents the History object for the document windowinnerHeight
This property represents the height of the content area (viewport) of the current window including horizontal scrollbarsinnerWidth
This property returns the width of the content area (viewport) of the current window including vertical scrollbarslength
This property represents the number of <iframe> tags in the current windowframeElement
This property can be used to get the element in which the window is embedded, or null if the window is not embedded.localStorage
Return the reference to the local storage object and allows us to save key/value pairs in a web browser. Stores the data with no expiration datelocation
This property is used to represent the location object for the current windowname
This property can be used to set or get the name of a windownavigator
Returns the Navigator object for the windowisSecureContext
This property indicates whether a context has the capability of using features that require secure contexts.opener
Returns a reference to the window that is opened in the current windowouterHeight
To get the outer height of the browser window, including toolbars/scrollbarsouterWidth
To get the outer width of the browser window, including toolbars/scrollbarspageXOffset
This is an alias of window.scrollXpageYOffset
This is an alias for window.scrollYparent
Returns a reference to the parent window or subframe of the current windowstatus
It is used to get or set the text in the status bar at the bottom of the browser.window.window
To get the reference to the current windowscreen
It is used to get the reference to the screen object for the windowscreenLeft or screenX
Represents the horizontal coordinate of the window relative to the screenscreenTop or screenY
Represents the vertical coordinate of the window relative to the screensessionStorage
Allows saving key/value pairs in a web browser. Stores the data for one sessionself
to get the current window referencetop
This property returns the reference to the topmost window in the window hierarchy.Methods
alert()
to show an alert box with a text message and an OK buttonatob()
to decodes a base-64 encoded stringblur()
This method blurs the current window and removes focusbtoa()
To encodes a string in base-64clearInterval()
Clears a timer set with setInterval() method.clearTimeout()
It clears a timer set by setTimeout()close()
It is used to the current window