Open In App

HTML DOM document visibilityState Property

The visibilityState property returns the visibility of the document. This is a read-only property.

Syntax:



letvis = document.visibilityState;

Return Value:

Example: In this example, we are using the above-explained property.






<!DOCTYPE html>
<html>
   
<body>
    <h1>GeeksforGeeks</h1>
 
    <button onclick="get()">
        Get visibility
    </button>
 
    <script type="text/javascript">
        function get() {
            let m = document.visibilityState;
            console.log(m);
        }
    </script>
</body>
   
</html>

Output:

 

Supported Browsers:

Article Tags :