Detect fullscreen mode

前端 未结 16 2159
谎友^
谎友^ 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条回答
  •  猫巷女王i
    2020-11-28 08:18

    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
    }
    

提交回复
热议问题