HTML DOM defaultView Property Last Updated : 30 Aug, 2024 Comments Improve Suggest changes Like Article Like Report The DOM defaultView property in HTML is used to return the document Window Object. The window object is the open windows in the browser. Syntax:document.defaultView Return Value: It is used to return the current Window Object. Example 1: In this example use the defaultView property to get the window object and display it in a <p> element when the button is clicked. The content is centered and styled. html <!DOCTYPE html> <html> <head> <title> DOM defaultView Property </title> </head> <body style="text-align:center"> <h1 style="color:green">GeeksForGeeks</h1> <h2>DOM defaultView Property </h2> <button onclick="geeks()">Submit</button> <p id="sudo"></p> <script> function geeks() { let doc = document.defaultView; document.getElementById("sudo").innerHTML = doc; } </script> </body> </html> Output: Example 2: This example is used to return the width and height of the Windows. html <!DOCTYPE html> <html> <head> <title> DOM defaultView Property </title> </head> <body> <center> <h1 style="color:green;">GeeksForGeeks</h1> <h2>DOM defaultView Property </h2> <button onclick="Geeks()">Submit</button> <p id="sudo"></p> <!-- script to find window size --> <script> function Geeks() { let def_view = document.defaultView; let width = def_view.innerWidth; let height = def_view.innerHeight; document.getElementById("sudo").innerHTML = "Width: " + width + "<br>Height: " + height; } </script> </center> </body> </html> Output: Supported Browsers: The browser supported by DOM defaultView property are listed below:Google ChromeEdge FirefoxOperaSafari Comment More infoAdvertise with us Next Article HTML DOM defaultView Property M manaschhabra2 Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML DOM nodeName Property The nodeName property is used to return the name of the specified node as a string. It returns different values for different nodes such as if the node attributes, then the returned string is the attribute name, or if the node is an element, then the returned string is the tag name. It is a read-onl 2 min read HTML DOM textContent Property The textContent property in HTML is used to set or return the text content of the specified node and all its descendants. This property is very similar to nodeValue property but this property returns the text of all child nodes.Syntax: It is used to set the text of node. node.textContent = textIt is 2 min read HTML ondrop Event Attribute The ondrop event attribute is used to drag an element or text and drop it into a valid droppable location or target. The drag and drop is a common feature of HTML 5. There are different events that are used and occur before ondrop event. Events occur on the draggable targetEvents occur on the drop t 3 min read HTML DOM item() Method The item() method is used to return the node at the specified index. The nodes are sorted as they appear in the source code. The index of the node list starts with 0. Syntax:nodelist.item( index )ornodelist[ index ] Parameters: This method accepts single parameter index which is used to hold the ind 2 min read HTML DOM Style borderRight Property The DOM style borderRight property is used to set or return the three different border-right properties such as border-right-width, border-right-style, and border-right-color of an element. Syntax: It returns the borderRight Property.object.style.borderRightIt is used to set the borderRight property 2 min read HTML DOM Style borderTop Property The DOM style borderTop property is used to set or return the three different border-top property such as border-top-width, border-top-style, and border-top-color of an element. Syntax: It returns the borderTop property. object.style.borderTopIt is used to set the borderTop property. object.style.bo 2 min read HTML DOM documentElement Property The DOM documentElement property is used to return the documentElement as an Element Object. It is a read-only property. It returns a <HTML> Element. Syntax:document.documentElement Return Value: It returns the documentElement of the document or an element object. Example: Below program illust 2 min read HTML DOM Style borderLeft Property HTML DOM Style borderLeft property allows manipulation of the left border style of an element via JavaScript. It controls the border's width, style, and color, affecting the element's visual presentation and layout. HTML DOM Style borderLeft Property Syntax:Get the borderLeft Property.object.style.b 2 min read HTML DOM setNamedItem() Method The setNamedItem() method is used to add a particular node to an attribute node using its name. These attribute nodes are collectively called as namedNodeMap. It can be accessed through a name. If a node is already present in the document, it will replace it and return the updated value. The setName 2 min read HTML DOM scripts Collection The DOM scripts Collection in HTML is used to return the collection of all <script> elements in an HTML document. The script elements are sorted as appear in the sourcecode. Syntax: document.scripts Property Value: It returns the single value length which is the collection of all script eleme 2 min read Like