Detecting if a browser is in full screen mode

后端 未结 17 1790
误落风尘
误落风尘 2020-11-27 06:10

Is there any way of reliably detecting if a browser is running in full screen mode? I\'m pretty sure there isn\'t any browser API I can query, but has anyone worked it out b

17条回答
  •  有刺的猬
    2020-11-27 06:52

    The Document read-only property returns the Element that is currently being presented in full-screen mode in this document, or null if full-screen mode is not currently in use.

    if(document.fullscreenElement){
      console.log("Fullscreen");
    }else{
      console.log("Not Fullscreen");
    };
    

    Supports in all major browsers.

提交回复
热议问题