码迷,mamicode.com
首页 > Web开发 > 详细

Js 实现全屏

时间:2017-08-04 19:24:05      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:screen   cti   add   html   listen   bsp   全屏   nstat   dev   

<input id="Button1" type="button" value="开始全屏" onclick="kaishi()" />
<input id="Button2" type="button" value="关闭全屏" onclick="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>

 

Js 实现全屏

标签:screen   cti   add   html   listen   bsp   全屏   nstat   dev   

原文地址:http://www.cnblogs.com/lbonet/p/7286624.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!