功能介绍:右键菜单做了一个显示全屏和取消全屏功能,但是用了F11全屏后,js全屏取消不了,两种冲突了!下面介绍一下解决方法!
var isFull = Math.abs(window.screen.height-window.document.documentElement.clientHeight) <= 17 window.onresize = function () { isFull = Math.abs(window.screen.height-window.document.documentElement.clientHeight) <= 17 }
// 阻止F11键默认事件,用HTML5全屏API代替 window.addEventListener('keydown', function (e) { e = e || window.event if (e.keyCode===122 && !isFull) { e.preventDefault() enterFullScreen() } })
// 打开浏览器全屏模式 function enterFullScreen () { let el = document.documentElement let rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen if (rfs) { // typeof rfs != "undefined" && rfs rfs.call(el) } else if (typeof window.ActiveXObject !== 'undefined') { // for IE,这里其实就是模拟了按下键盘的F11,使浏览器全屏 let wscript = new ActiveXObject('WScript.Shell') if (wscript != null) { wscript.SendKeys('{F11}') } } }
// 退出全屏 function exitFullScreen () { let el = document let cfs = el.cancelFullScreen || el.mozCancelFullScreen || el.msExitFullscreen || el.webkitExitFullscreen || el.exitFullscreen if (cfs) { // typeof cfs != "undefined" && cfs cfs.call(el) } else if (typeof window.ActiveXObject !== 'undefined') { // for IE,这里和fullScreen相同,模拟按下F11键退出全屏 let wscript = new ActiveXObject('WScript.Shell') if (wscript != null) { wscript.SendKeys('{F11}') } } }
完美解决el-table设置高度和合计showsummary冲突不显示问题
上面是“F11全屏功能和js全屏功能冲突解决方法”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2255.html
workflows工作流
令人着迷的一只老虎ComfyUI工作流
一个外国人在吹奏萨克斯ComfyUI工作流
水中一台精致而破旧的老式电视鱼缸ComfyUI工作流
一个女孩骑着一辆生锈的现代摩托车
迷人的月光,发光的花朵
小鸟在黑暗的天空中优雅地跳舞
森林里一只邪恶的树妖ComfyUI工作流
一张由表情符号组成的照片ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!