Click here to Skip to main content
15,065,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Is there any javascript function/s that will tell me if the current
browser window is in full screen mode or not?
Posted

1 solution

Try this:

Must be used after the page is fully loaded, so in page onload or used in a function after loading is complete.

XML
function IsFullScreen( )
{
      // Variables
      var intScreenHeight = window.screen.height;
      var intBodyOffSet = document.body.offsetHeight;
      var intFullScreenDifference = 26;
      var blnIsFullScreen = false; // Assume No
      // Does the Screen Height - the Body offset = Full Screen Difference
      if( ( intScreenHeight - intBodyOffSet ) == intFullScreenDifference )
      {
            // Yes, were full screen
            blnIsFullScreen = true;
      }
      // Return
      return blnIsFullScreen;
}

</script>

<html>
      <body onload="alert( IsFullScreen( ) );">
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      </body>
</html>


Good luck!
   
Comments
Raghavendra HG 3-Aug-10 2:48am
   
Man this is not working. I tried in IE8...
E.F. Nijboer 3-Aug-10 5:13am
   
Below some links for getting the viewport size (visible document size) and screen size. You should be able to determine if the page is displayed fullscreen or not.

http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/

http://andylangton.co.uk/articles/javascript/browser-screen-resolution/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900