• js 切换全屏


    公司有一个需求就是点击某一个按钮实现全屏切换功能,然后呢我就在网上扒了段代码。封装了一下。使用的小伙伴们可以看看哦!

    切换全屏代码

    <!DOCTYPE html>
    <html>
    
        <head>
            <meta charset="UTF-8">
            <title>切换全屏代码</title>
        </head>
    
        <body>
    
            <input type="button" value="全屏" onclick="Full_switch.fullScreen();" />
            <input type="button" value="退出全屏" onclick="Full_switch.exitFullScreen();" />
            <script type="text/javascript">
                (function(win) {
                    var switchs = {
                        fullScreen: function() { //全屏方法
                            var el = document.documentElement;
                            var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen;
                            if(typeof rfs != "undefined" && rfs) {
                                rfs.call(el);
                            } else if(typeof win.ActiveXObject != "undefined") {
                                var wscript = new ActiveXObject("WScript.Shell");
                                if(wscript != null) {
                                    wscript.SendKeys("{F11}");
                                }
                            }
                        },
                        exitFullScreen: function() { //退出全屏方法
                            var el = document,
                                cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen,
                                wscript;
    
                            if(typeof cfs != "undefined" && cfs) {
                                cfs.call(el);
                                return;
                            }
    
                            if(typeof win.ActiveXObject != "undefined") {
                                wscript = new ActiveXObject("WScript.Shell");
                                if(wscript != null) {
                                    wscript.SendKeys("{F11}");
                                }
                            }
                        },
                    }
                    win.Full_switch =switchs;
                })(window);
            </script>
        </body>
    
    </html>

    预览地址

    点击查看

  • 相关阅读:
    python爬取酷狗音乐
    python爬取酷我音乐
    排列组合+逆元模板
    python爬取QQVIP音乐
    一维数组的动态和
    买卖股票的最佳时机 II
    最佳买卖股票时机含冷冻期
    买卖股票的最佳时机
    子集
    最短无序连续子数组
  • 原文地址:https://www.cnblogs.com/xiaoxiaokun/p/7232363.html
Copyright © 2020-2023  润新知