$(function(){ $("#btn").click(function(){ var docElm = document.documentElement; //W3C if(docElm.requestFullscreen) { docElm.requestFullscreen(); } //FireFox else if(docElm.mozRequestFullScreen) { docElm.mozRequestFullScreen(); } //Chrome等 else if(docElm.webkitRequestFullScreen) { docElm.webkitRequestFullScreen(); } //IE11 else if(elem.msRequestFullscreen) { elem.msRequestFullscreen(); } }); $(document).keypress(function(e){ if(e.keyCode==27){ alert("关闭页面"); //W3C退出全屏 /*if (document.exitFullscreen) { document.exitFullscreen(); } //FireFox else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } //Chrome等 else if (document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } //IE11 else if (document.msExitFullscreen) { document.msExitFullscreen(); }*/ } }); });
下载地址:js全屏
上一篇:js正则注意事项