Sunday, November 16, 2025
HomeLanguagesJavascriptHTML DOM document visibilityState Property

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:

  • visible: When page content may be visible to the user.
  • hidden: When page content is not visible to the user.
  • prerender: when the document is being prerendered and is not visible to the user.

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

HTML




<!DOCTYPE html>
<html>
   
<body>
    <h1>neveropen</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:

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Safari
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32402 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6769 POSTS0 COMMENTS
Nicole Veronica
11920 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11990 POSTS0 COMMENTS
Shaida Kate Naidoo
6897 POSTS0 COMMENTS
Ted Musemwa
7150 POSTS0 COMMENTS
Thapelo Manthata
6851 POSTS0 COMMENTS
Umr Jansen
6843 POSTS0 COMMENTS