Detect fullscreen mode Detect fullscreen mode jquery jquery

Detect fullscreen mode


As you have discovered, browser compatibility is a big drawback. After all, this is something very new.

However, since you're working in JavaScript, you have far more options available to you than if you were just using CSS.

For example:

if( window.innerHeight == screen.height) {    // browser is fullscreen}

You can also check for some slightly more loose comparisons:

if( (screen.availHeight || screen.height-30) <= window.innerHeight) {    // browser is almost certainly fullscreen}


an event is fired when the browser changes full screen mode. You can use that to set a variable value, which you can check to determine if the browser is full screen or not.

this.fullScreenMode = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen; // This will return true or false depending on if it's full screen or not.$(document).on ('mozfullscreenchange webkitfullscreenchange fullscreenchange',function(){       this.fullScreenMode = !this.fullScreenMode;      //-Check for full screen mode and do something..      simulateFullScreen(); });var simulateFullScreen = function() {     if(this.fullScreenMode) {            docElm = document.documentElement            if (docElm.requestFullscreen)                 docElm.requestFullscreen()            else{                if (docElm.mozRequestFullScreen)                    docElm.mozRequestFullScreen()                else{                   if (docElm.webkitRequestFullScreen)                     docElm.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)                }            }     }else{             if (document.exitFullscreen)                   document.exitFullscreen()             else{                   if (document.mozCancelFullScreen)                      document.mozCancelFullScreen()                  else{                     if (document.webkitCancelFullScreen)                          document.webkitCancelFullScreen();                  }             }     }     this.fullScreenMode= !this.fullScreenMode}


This will work on IE9+ and other modern browsers

function isFullscreen(){ return 1 >= outerHeight - innerHeight };

Using "1" (instead of zero) because the system, at times, might just reserve a one pixel height for mouse interaction with some hidden or sliding command bars, in which case the fullscreen detection would fail.

  • will also work for any separate document-element going on the full screen mode at any time.