SVG Window.document Property

Last Updated : 30 Mar, 2022

The SVG Window.document property returns a reference to the document contained in the window.

Syntax:

var object = window.document

Return value: This property returns a reference to the document contained in the window.

Example 1:

HTML
<!DOCTYPE html>
<html>

<body>
    <svg viewBox="0 0 1000 1000" 
        xmlns="http://www.w3.org/2000/svg">
        
        <circle cx="200" cy="200" r="50"></circle>
        
        <script type="text/javascript">
            console.log(window.document);
        </script>
    </svg>
</body>

</html>

Output:

Example 2:

HTML
<!DOCTYPE html>
<html>

<body>
    <svg viewBox="0 0 1000 1000" 
        xmlns="http://www.w3.org/2000/svg">
        
        <text x="200" y="200">
            GeeksforGeeks
        </text>
        
        <script type="text/javascript">
            console.log(window.document);
        </script>
    </svg>
</body>

</html>

Output:

 

Comment