Laya引擎开发的H5游戏实现全屏解决方法 Laya引擎开发的H5游戏实现全屏解决方法 , H5游戏怎样实现全屏. 本文转自csdn社区,作者放荡不羁的码农,版权归原作者所有,本站只是保存以作学习使用。 在打包出的入口文件 index.html 中加入以下代码: /** * 浏览器全屏 */ //检测是否全屏 function checkFull() { var isFull = document.fullscreenEnabled || window.fullScreen || document.webkitIsFullScreen || document.msFullscreenEnabled; if (isFull === undefined) isFull = false; return isFull; } //设置全屏 function setFullScreen() { var el = document.documentElement; var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen; if (typeof rfs != "undefined" && rfs) { rfs.call(el); } else if (typeof window.ActiveXObject != "undefined") { var wscript = new ActiveXObject("WScript.Shell"); if (wscript != null) { wscript.SendKeys("{F11}"); } } } window.onclick = function (e) { if (!checkFull()) { setFullScreen(); } else { // alert('已经处于全屏') } } |