首页 > 其他分享 >解决监听全屏状态下esc退出全屏

解决监听全屏状态下esc退出全屏

时间:2022-12-02 09:34:17浏览次数:57  
标签:false undefined isFull esc 全屏 document 监听

 1 //判断是否全屏
 2 const checkFull=()=> {
 3     var isFull =
 4         document.fullscreenElement ||
 5         document.mozFullScreenElement ||
 6         document.webkitFullscreenElement;//兼容不同浏览器
 7     //to fix : false || undefined == undefined
 8     if (isFull === undefined) isFull = false;
 9     return isFull;
10 }
11 //监听窗口退出全屏解决无法监听Esc按键
12 window.onresize = function () {
13     if (!checkFull()) {
14         //要执行的动作
15         isFull.value = false;//样式改变
16        console.log("退出全屏")
17     }
18 }
  转载地址:https://blog.csdn.net/xiaoyanli8077/article/details/89537911  

标签:false,undefined,isFull,esc,全屏,document,监听
From: https://www.cnblogs.com/lisir-blogshare/p/16943413.html

相关文章