how to check browser window visibility using jquery

Whenever you switch the browser or tab then execute some events.

Below is html & jquery code  to check your browser window visibility
Using this code : Check the title bar when you are switch the browser or tab.

If title bar display “Active” it means you are on current tab or browser
If title bar display “Inactive” it means you are out of current tab or browser

Code :

<html>
    <head>
        <title>Hello !!</title>
   
<script src=”//code.jquery.com/jquery-1.11.3.min.js”></script>
<script type=”text/javascript”>
    $(document).ready(function(){
     $(window).blur(function(){
          document.title = ‘Inactive’;
     });
     $(window).focus(function(){
          document.title = ‘Active’;
     });
});
</script>
 </head>
</html>


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *