美文网首页
全屏模式

全屏模式

作者: RossWen | 来源:发表于2017-07-27 09:48 被阅读0次
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>desktop</title>
    </head>
    <body id="content">
    <b onclick="fullscreen()">全屏</b>
    </body>
    
    <script type="text/javascript" charset="utf-8">
        function fullscreen(){
            if (document.fullscreenElement ||
                    document.mozFullScreenElement ||
                    document.webkitFullscreenElement ||
                    document.msFullscreenElement) {
                if (document.exitFullscreen) {
                    document.exitFullscreen();
                } else if (document.mozCancelFullScreen) {
                    document.mozCancelFullScreen();
                } else if (document.webkitExitFullscreen) {
                    document.webkitExitFullscreen();
                } else if (document.msExitFullscreen) {
                    document.msExitFullscreen();
                }
            } else {
                if (document.documentElement.requestFullscreen) {
                    document.documentElement.requestFullscreen();
                } else if (document.documentElement.mozRequestFullScreen) {
                    document.documentElement.mozRequestFullScreen();
                } else if (document.documentElement.webkitRequestFullscreen) {
                    document.documentElement.webkitRequestFullscreen();
                } else if (document.documentElement.body.msRequestFullscreen) {
                    document.documentElement.body.msRequestFullscreen();
                }
            }
        }
    </script>
    </html>
    

    相关文章

      网友评论

          本文标题:全屏模式

          本文链接:https://www.haomeiwen.com/subject/fraakxtx.html