zoukankan      html  css  js  c++  java
  • 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>

    预览地址

    点击查看

  • 相关阅读:
    程序员创业必读的几本书
    Linux系统下word转pdf,xls转pdf,ppt转pdf
    Linux系统下word转pdf,xls转pdf,ppt转pdf
    文件流演示案例(一)
    记事本程序
    Struts2入门(二)
    MyEclipse6.5注册方法
    使用ASP.NET上传图片汇总
    sql server 2005 (select查询语句用法)
    千万级分页存储过程
  • 原文地址:https://www.cnblogs.com/xiaoxiaokun/p/7232363.html
Copyright © 2011-2022 走看看