退出全屏监听ESC事件,这里没有用keydown来监听,因为全屏时候keydown监听不到
浏览器故意不上监听ESC键的,跟网页加载完成之后不能用程序使浏览器全屏一样的道理,避免开发者恶意全屏,不啰嗦,解决办法如下:
window.onresize = function(){
if(!checkFull()){
//要执行的动作
}
}
function checkFull(){
var isFull = document.fullscreenEnabled || window.fullScreen || document.webkitIsFullScreen || document.msFullscreenEnabled;
//to fix : false || undefined == undefined
if(isFull === undefined) isFull = false;
return isFull;
}