Skip to content
Related Articles

Related Articles

HTML DOM window document property

View Discussion
Improve Article
Save Article
  • Last Updated : 13 Jun, 2022
View Discussion
Improve Article
Save Article

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.

html




<!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>

Output:

Before Clicking Button:

After Clicking Button: 

In Console, document reference is:

Supported Browsers:

  • Google Chrome 1
  • Edge 12
  • Firefox 1
  • Safari 1
  • Opera 12.1
  • Internet Explorer 4
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!