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

 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 }
 
 
posted @ 2022-12-02 09:21  奔跑的哈密瓜  阅读(629)  评论(0编辑  收藏  举报