js监听全屏下的esc事件
2021腾讯云限时秒杀,爆款1核2G云服务器298元/3年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
2021阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址:https://www.aliyun.com/minisite/goods
推荐:推荐JS压缩工具ESC
昨天将CheckBox转Text的代码从HTML中剥离出来之后,发现为了实现这么简单的一个效果,JS文件竟有5K,差不多相当于Lite版的Jquery了,寒! 于是想着找一些工具
window.onresize = function() {
if (!checkFull()) {
//触发esc事件,执行业务逻辑。
}
};
function checkFull() {
var isFull = document.fullscreenEnabled
|| window.fullScreen
|| document.webkitIsFullScreen
|| document.msFullscreenEnabled;
if (isFull === undefined)
isFull = false;
return isFull;
}
推荐:js事件监听机制
1、addEventListener 用于firefox 2、attachEvent 用于ie