zoukankan      html  css  js  c++  java
  • js 实现各浏览器全屏

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>js 实现各浏览器全屏</title>
    </head>
    <body>
        <button onclick="screen.full()">现代浏览器全屏</button>
    
        <button onclick="screen.exit()">现代浏览器退出</button>
    
        <button onclick="screen.iefull()">低版本ie全屏</button>
    </body>
    <script type="text/javascript">
        // 全屏
        window.screen.full = function() {
            var el = document.documentElement;
            var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen; 
            if(typeof rfs != "undefined" && rfs) {
                rfs.call(el);
            } else {
                return;
            };
        };
        // 退出全屏
        window.screen.exit = function() {
            if (document.exitFullscreen) {  
                document.exitFullscreen();  
            }  
            else if (document.mozCancelFullScreen) {  
                document.mozCancelFullScreen();  
            }  
            else if (document.webkitCancelFullScreen) {  
                document.webkitCancelFullScreen();  
            }  
            else if (document.msExitFullscreen) {  
                document.msExitFullscreen();  
            } 
            if(typeof cfs != "undefined" && cfs) {
                cfs.call(el);
            }
        };
         //ie低版本的全屏,退出全屏都这个方法
         //注:ie调用ActiveX控件,需要在ie浏览器安全设置里面把 ‘未标记为可安全执行脚本的ActiveX控件初始化并执行脚本’ 设置为启用
        window.screen.ieFull = function() {
            var el = document.documentElement;
            var rfs =  el.msRequestFullScreen;
            if(typeof window.ActiveXObject != "undefined") {
                //这的方法 模拟f11键,使浏览器全屏
                var wscript = new ActiveXObject("WScript.Shell");
                if(wscript != null) {
                    wscript.SendKeys("{F11}");
                }
            }
        };
    </script>
    </html>
      
  • 相关阅读:
    INT最值
    约瑟夫问题
    word里的图片怎么复制出来
    必须掌握的8个dos命令
    vld(Visual Leak Detector 内存泄露检测工具
    sscanf,sscanf_s及其相关用法
    游戏开发梦开始的地方笔记
    关于字符编码,你所需要知道的
    CreateMutex创建互斥体可以用于只运行进程的一个实例
    sprintf,你知道多少?
  • 原文地址:https://www.cnblogs.com/zhangchs/p/10876853.html
Copyright © 2011-2022 走看看