fullscreenchange全屏事件监听,兼容chrome、safari

苏法
2023-12-01

API参考:Fullscreen API 全屏显示网页

        ['fullscreenchange','webkitfullscreenchange','mozfullscreenchange'].forEach((item,index) => {
          window.addEventListener(item, () => this.fullscreenchange());
        })
   	//  监听全屏事件触发
      fullscreenchange() {
        let isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
        if (isFullScreen) {
          //  进入全屏
        } else {
          //  退出全屏
          
        }
      },
 类似资料: