html5 js 实现浏览器全屏效果(F11)

首先给大家推荐一下我老师大神的人工智能教学网站。教学不仅零基础,通俗易懂,而且非常风趣幽默,还时不时有内涵黄段子!点这里可以跳转到网站

           最近项目中需要浏览器全屏的效果、我查了很多资料、终于、找到了一段代码、说是能兼容google chrome 15 +, safri5.1+,firfox10+,IE11支持 、我只试验了火狐可以、360、以及IE8是没有成功滴、下面给大家发下代码、复制到HTML的页面就可以实现啦!

<input id="Button1" type="button" value="开始全屏" οnclick="kaishi()" /><input id="Button2" type="button" value="关闭全屏" οnclick="guanbi()" /> <script>    function kaishi()    {          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();        }    }     function guanbi() {          if (document.exitFullscreen) {            document.exitFullscreen();        }        else if (document.mozCancelFullScreen) {            document.mozCancelFullScreen();        }        else if (document.webkitCancelFullScreen) {            document.webkitCancelFullScreen();        }        else if (document.msExitFullscreen) {            document.msExitFullscreen();        }    }        document.addEventListener("fullscreenchange", function () {                fullscreenState.innerHTML = (document.fullscreen) ? "" : "not ";    }, false);            document.addEventListener("mozfullscreenchange", function () {               fullscreenState.innerHTML = (document.mozFullScreen) ? "" : "not ";    }, false);            document.addEventListener("webkitfullscreenchange", function () {                fullscreenState.innerHTML = (document.webkitIsFullScreen) ? "" : "not ";    }, false);        document.addEventListener("msfullscreenchange", function () {                fullscreenState.innerHTML = (document.msFullscreenElement) ? "" : "not ";    }, false);    </script> 

出处:http://camnpr.com/javascript/1141.html

最近做项目忙死了……………………

————————————————————chenchen好久没冒泡了——————————————————————

点这里可以跳转到人工智能网站

发表评论