Skip to content
Related Articles

Related Articles

HTML DOM document visibilityState Property

View Discussion
Improve Article
Save Article
  • Last Updated : 05 Jul, 2020

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


var vis = document.visibilityState;

Return Value:

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



<!DOCTYPE html>
    <button onclick="get()">
        Get visibility
    <script type="text/javascript">
        function get() {
            var m = document.visibilityState;


Before Click the Button:

After Click the Button:

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Safari
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!