The window document returns a reference to the document contained in the current window.
Syntax:
doc = window.document;
Return Value: This property returns a reference to the document.
Example: In this example, we will get the title of the document using that document reference.
<!DOCTYPE HTML> <html> <head> <title>window document property</title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <p> HTML | window document property </p> <button onclick = "Geeks()"> Click Here </button> <p id="a"> </p> <script> var a = document.getElementById("a"); function Geeks() { console.log(window.document) a.innerHTML=window.document.title; } </script> </body> </html> |
chevron_right
filter_none
Output:
Before Clicking Button:
After Clicking Button:
In Console, document reference is:
Supported Browsers:
- Google Chrome
- Edge
- Firefox
- Safari
- Opera
- Internet Explorer
Recommended Posts:
- HTML DOM document visibilityState Property
- HTML DOM Document hidden Property
- HTML DOM document contentType Property
- HTML DOM document plugins Property
- HTML DOM document scrollingElement Property
- HTML DOM document location Property
- HTML | Window name Property
- HTML | Window self( ) Property
- HTML | Window top( ) Property
- HTML DOM window crypto property
- HTML DOM Window visualViewport property
- HTML DOM Window speechSynthesis property
- HTML DOM Window scrollX property
- HTML DOM Window.location Property
- HTML DOM Window navigator Property
- HTML DOM Window origin Property
- HTML DOM window customElements property
- HTML DOM window event property
- HTML DOM window devicePixelRatio property
- HTML | Window outerHeight Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


