Detect fullscreen mode

前端 未结 16 2130
谎友^
谎友^ 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:35

    Here is the most up to date answer. fully browser compatible with all the prefixes:

    function IsFullScreen() {
         return !!(document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement)
    }
    

    credit to https://developers.google.com/web/fundamentals/native-hardware/fullscreen/

    DEMO

    function IsFullScreen() {
      console.log(!!(document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement))
    }

提交回复
热议问题