The Wayback Machine - https://web.archive.org/web/20240926150213/https://www.geeksforgeeks.org/properties-of-window-object/
Open In App

Properties of Window Object

Last Updated : 31 Aug, 2021
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The window object is the topmost object of DOM hierarchy. It represents a browser window or frame that displays the contents of the webpage. Whenever a window appears on the screen to display the contents of document, the window object is created. The properties and methods of Window object that are commonly used are listed in the below table:

Properties of the Window Object

Property Name

Purpose

Closed It holds a Boolean value that represents whether the window is closed or not.
console It returns a reference to the console object which provides access to the browser’s debugging console.
defaultStatus It is used to define the default message that will be displayed in the status bar when no activity is carried on by the browser.
controllers It returns the XUL controller objects for the current Chrome window.
customElements It returns a reference to the CustomElementRegistry object, which can be used to register new custom elements and also get information about already registered custom elements.
crypto It returns the browser crypto object.
devicePixelRatio It returns the ratio between physical pixels and device independent pixels in the current display.
Document It returns a reference to the document object of that window.
DOMMatrix It returns a reference to a DOMMatrix object, which represents 4×4 matrices, suitable for 2D and 3D operations.
frames[] It represents an array that contains all the frames of a given window.
DOMPoint It returns a reference to a DOMPoint object, which represents a 2D or 3D point in a coordinate system.
History It provides information of the URLs visited in the current window.
Length It represents the number of frames in the current window.
DOMRect It returns a reference to a DOMRect object, which represents a rectangle.
fullScreen This property indicates whether the window is displayed in full screen or not.
Location It contains the URL of the current window.
innerHeight It is used to get the height of the content area of the browser window.
innerWidth It is used to get the width of the content area of the browser window.
Name It contains name of the referenced window.
Opener It contains a reference to the window that opened the current window.
Parent It refers to the frame set in which the current frame is contained.
Screen It refers to the screen object
Self It provides another way to refer the current window.
Status It overrides the defaultStatus and places a message in the status bar.
Top It returns a reference to the topmost window containing a frame if many windows are opened.
Window It returns the current window or frame.
Navigator It returns a reference to the navigator object.
outerHeight It will get height of the outside of the browser window.
outerWidth It will get width of the outside of the browser window.
Toolbar It will result the toolbar object, whose visibility can be toggled in the window.

To access the properties of the window object, you will specify object name followed by a period symbol (.) and the property name. 
 

Syntax:

window.property_name

Example:

HTML




<!DOCTYPE html>
<html>
 
<head>
    <script language="JavaScript">
        function winopen() {
            window.open("https://www.geeksforgeeks.org")
        }
        function showstatus() {
            window.status =
                "Opening GeeksforGeeks Home page";
        }
    </script>
</head>
 
<body onload="showstatus()">
    <input type="button" name="btn"
        value="Open GeeksforGeeks"
        onclick="winopen()">
</body>
 
</html>


Output:

Before Click the Button:

After Click the button:



Similar Reads

Difference between window.location.href, window.location.replace and window.location.assign in JavaScript
Window.location is a property that returns a Location object with information about the document's current location. This Location object represents the location (URL) of the object it is linked to i.e. holds all the information about the current document location (host, href, port, protocol, etc.) All three commands are used to redirect the page t
4 min read
Web Window API | Window locationbar property
In Web API Window.locationbar property returns the object of locationbar, for which we can check the visibility. Syntax: objectReference = window.locationbar Example: Check the visibility. <!DOCTYPE html> <html> <head> <title> Window locationbar property </title> <style> a:focus { background-color: magenta; }
1 min read
Web Window API | Window scrollbars property
In Web APIWindow.scrollbars property returns the object of scrollbars, for which we can check the visibility. Syntax : objectReference = window.scrollbars Example : Check the visibility <!DOCTYPE html> <html> <head> <title> Window scrollbars property </title> <style> a:focus { background-color: magenta; } </st
1 min read
Web Window API | DOM Window fullscreen property
The Window interface has a fullscreen property which tells whether the window is displayed in fullscreen mode or not. Syntax: BoolVal = windowReference.fullScreen; Return value: Boolean True: If windows is in fullscreen mode. False: If windows are not in fullscreen mode. Example : <!DOCTYPE html> <html> <head> <title> Window
1 min read
Web Window API | Window personalbar property
In Web API Window.personalbar property returns the object of personalbar, for which we can check the visibility. Syntax: objectReference = window.personalbar Example: Check the visibility <!DOCTYPE html> <html> <head> <title> Window personalbar property </title> <script type="text/javascript"> function
1 min read
Web Window API | Window statusbar property
In Web API Window.statusbar property returns the object of statusbar, for which we can check the visibility. Syntax: objectReference = window.statusbar Example: Check the visibility <!DOCTYPE html> <html> <head> <title> Window statusbar property </title> <script type="text/javascript"> function getvisib
1 min read
Web Window API | Window toolbar property
In HTML Window.toolbar property returns the object of toolbar, for which we can check the visibility. Syntax: objectReference = window.toolbar Example: Check the visibility C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt; Window toolbar property &lt;/title&gt; &lt;script type=&
1 min read
Web Window API | Window menubar property
In HTML Window.menubar property returns the object of menubar, for which we can check the visibility. Syntax: objectReference = window.menubar Example: This example uses Window.menubar property to check the visibility of menubar object. C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt; Window m
1 min read
Difference between window.onkeypress and window.document.body.onkeypress
The onkeypress event can be triggered in JavaScript using both: window.onkeypresswindow.document.body.onkeypress To understand the difference between the two we need to have a look at the HTML DOM (Document Object Model): DOM is a model that represents the HTML document as a tree structure.The tree structure has the root node as a Document object.O
2 min read
Window | Window.requestAnimationFrame() Method
Nowadays, various web development technologies are introduced to create elegant web pages. While talking about elegant web pages, one of the most important things that come to mind is animation. There are many ways to generate them, modern CSS is one of them but JavaScript has always been a power-packed option to do so. The requestAnimationFrame()
3 min read
Javascript Window Blur() and Window Focus() Method
JavaScript provides various methods to manipulate browser windows, two of which are window.blur() and window.focus(). These methods are particularly useful when managing the user interface and enhancing the user experience by controlling window focus. Javascript Window Blur()Javascript Window Blur() method is used to remove focus from the current w
3 min read
Javascript Window Open() & Window Close() Method
The Javascript Window.Open() method is used to open the web pages into a new window or a new tab. It depends on the browser settings and the values assigned to the parameter. Syntax: window.open(URL, name, specs, replace)Parameters: This method accepts four parameters as mentioned above and described below: URL: It is an optional parameter. It is u
3 min read
HTML DOM Window frames Properties
The HTML DOM Window frames property in HTML DOM is used to return the frame element in the form of an array object. This property represents all <iframe> elements in the current window. DOM Windowframe is a read-only property. Syntax: window.frames Properties: length property: It returns the number of iframe elements in the current window. lo
2 min read
HTML | DOM Window frameElement Properties
HTML DOM Window frameElement property returns the iframe element in which the window is embedded or stored. If it is not stored, in that case, it simply returns a null value. Syntax: window.frameElement Return Value: It returns an IFrame object or null. Example: C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;
1 min read
HTML DOM Window localStorage Properties
HTML DOM Window localStorage Properties allow you to store value pairs in web browsers using objects. It is a read-only property. This object is not expired even if the browser is closed. So, the data is never lost. Return Values: It returns  a Storage object. Syntax: SAVING data to localStorage using: localStorage.setItem("key", "value"); READING
2 min read
HTML | DOM Window defaultStatus Properties
The DefaultStatus property is used to set or return the default text in the status bar at the bottom side of the browser. Syntax: window.defaultStatus Return Type: The Default text in status bar. Example: <!DOCTYPE html> <html> <head> <title> HTML | DOM Window defaultStatus Properties </title> </head> <body
1 min read
JavaScript Window innerWidth and innerHeight Properties
The innerWidth property in JavaScript returns the width and innerHeight property returns the height of window content area.  Syntax: window.innerWidthwindow.innerHeightParameter: It doesn't require any parameters.  Return Value: It returns a number(Representing the Width and Height of the window's content area).  Note: For IE 8 i.e (Internet Edge 8
1 min read
HTML | DOM Window opener Properties
The Window opener property in HTML DOM is used to return the reference of newly created windows. This property is used to return the details of the source (parent) window. A window is opened using the window.open() method and closed using the window.opener.close() method. Syntax:window.openerReturn Value: It returns the reference of the created win
2 min read
Why Transition properties does not work with display properties ?
When we want to use transition for display:none to display:block, transition properties do not work. The reason for this is, display:none property is used for removing block and display:block property is used for displaying block. A block cannot be partly displayed. Either it is available or unavailable. That is why the transition property does not
2 min read
What is Window Object in JavaScript ?
In JavaScript, the window object is a global object that represents the browser window or, in the case of server-side JavaScript (e.g., with Node.js), the global environment. It serves as the top-level object in the browser's Document Object Model (DOM) hierarchy, providing a global context for executing JavaScript code. Features of the window obje
1 min read
Window Object in JavaScript
In JavaScript, the Window object represents the browser window that contains a DOM document. The Window object offers various properties and methods that enable interaction with the browser environment, including manipulating the document, handling events, managing timers, displaying dialog boxes, and more. Window Object PropertiesThe Window object
5 min read
Difference between id and cid properties on a model object in Backbone.js
Backbone.js is a compact library used to organize JavaScript code. An MVC/MV* framework is another term for it. If MVC is unfamiliar to you, it is merely a technique for designing user interfaces. The creation of a program's user interface is made considerably easier by JavaScript functions. BackboneJS provides a variety of building elements to aid
3 min read
How to get a subset of a javascript object's properties?
To get the subset of properties of a JavaScript Object, we make use of destructuring and Property Shorthand. The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.Syntax: subset = (({a, c}) => ({a, c}))(obj); Example1: Get subset of
2 min read
ASP ASPError Object Properties
ASP Code: The ASPCode is used for returning the string value which determines the error code that would be generated by the IIS server. This Property applies to Error Object. It is an inbuilt method of the Error object. Syntax: ASPError.ASPCode() ASPDescription: The ASPDescription is used to return a detailed description of an error. Syntax: ASPErr
2 min read
How to get an array of function property names from own enumerable properties of an object in JavaScript ?
Enumerable Properties: All the properties of an object that can be iterated using for..in loop or Object.keys() method are known as enumerable properties. In this article, we will see how to get an array of functions of an object that are enumerable. It can be achieved by following these 2 steps. Using Object.keys() method, we can get an array of a
2 min read
How to access object properties from result returned by async() function in JavaScript ?
In this article, we will see how to access the properties of a javascript object result returned by the async() function in Javascript. A javascript object property is a variable that is associated (read attached) with the object itself, i.e. the properties have a name and value is one of the attributes linked with the property, which defines the a
3 min read
How to copy properties from one object to another in ES6 ?
The properties of one object can be copied into another object through different methods. Here are some of those methods. Object.assign(): By using the Object.assign() method, all enumerable properties of one or more source objects are copied to the target object. This method returns the modified target object. The properties of the target object a
3 min read
How to make object properties immutable in TypeScript ?
In this article, we will try to understand how we could make object properties immutable in TypeScript. JavaScript is a highly dynamic and flexible language, hence making object properties in JavaScript immutable is a little bit typical (although we may implement it somehow using a const data type that doesn't work always). So here in TypeScript we
2 min read
How to read properties of an Object in JavaScript ?
Objects in JavaScript, it is the most important data type and forms the building blocks for modern JavaScript. These objects are quite different from JavaScript’s primitive data-types(Number, String, Boolean, null, undefined, and symbol) in the sense that these primitive data-types all store a single value each (depending on their types). In this a
2 min read
JavaScript Program to Access Non-Numeric Object Properties by Index
In JavaScript, we can access non-numeric object properties by their keys (property names) rather than by index, as objects are not indexed like arrays. Objects use key-value pairs to store data. But there are certain ways to achieve this using the properties of the objects. Approaches to access non-numeric object by Index in JavaScriptUsing Object.
2 min read