Detect fullscreen mode

前端 未结 16 2124
谎友^
谎友^ 2020-11-28 08:01

Modern desktop version of IE 10 is always fullscreen.

There is a living specification for :fullscreen pseudo-class on W3

But when I tried to det

相关标签:
16条回答
  • 2020-11-28 08:37

    Try this! Works for recent browsers.

    if (!window.screenTop && !window.screenY) {
        alert('Fullscreen mode......');
    }
    

    You can also use this jquery plugin for same.

    $(window).bind("fullscreen-on", function(e) {
    alert("FULLSCREEN MODE");
    });
    
    0 讨论(0)
  • 2020-11-28 08:38

    Here's another solution that might work for you:

    function isFullScreen() {
    return Math.abs(screen.width - window.innerWidth) < 10; 
    }
    

    I prefer to use width since it will help work around tabs and developer info at the bottom.

    0 讨论(0)
  • 2020-11-28 08:40

    Did you try $(window) instead of $(document). Follow one example http://webification.com/tag/detect-fullscreen-jquery.

    0 讨论(0)
  • 2020-11-28 08:43

    It is working in IE 8 and I am writing a specific web page for IE 8. I do not need to check if the other browsers support this or not.

    function isFullScreen(){
        return window.screenTop == 0 ? true : false;
    }
    
    0 讨论(0)
提交回复
热议问题