Open liujiusheng opened 7 years ago
打开全屏代码:
function launchFullScreen(element) { if (element.requestFullscreen) { element.requestFullscreen(); } else if (element.msRequestFullscreen) { element.msRequestFullscreen(); } else if (element.mozRequestFullScreen) { element.mozRequestFullScreen(); } else if (element.webkitRequestFullscreen) { element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); } }
关闭全屏代码:
function cancelFullScreen() { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } }
可通过window.resize= function(){}来监听是否处理全屏状态切换 可通过对比要全屏的元素和window.document.fullscreenElement判断是否处理全屏状态
参考资料:让你的页面瞬间全屏
打开全屏代码:
关闭全屏代码:
可通过window.resize= function(){}来监听是否处理全屏状态切换 可通过对比要全屏的元素和window.document.fullscreenElement判断是否处理全屏状态
参考资料:让你的页面瞬间全屏