• js指定区域全屏


    <html>
    
        <head>
    
            <title>js指定区域全屏</title>
    
            <style>
    
                #fulldiv {
    
                    background: #fff;
    
                    width: 100%;
    
                    text-align: center;
    
                    height: 100%;
    
                }
    
            </style>
    
        </head>
    
        <body>
    
            <h1>指定区域全屏测试</h1>
    
            <button id="btn">全屏按钮</button>
    
            <div id="content-main">
    
            <img src="C:UsersguobinDesktopIMG_3163.PNG" />
    
            </div>
    
        </body>
    
        <script>
    
            var fullscreen = false;
    
            let btn = document.getElementById('btn');
    
            let fullarea = document.getElementById('content-main')
    
            btn.addEventListener('click',function(){   
    
                if (fullscreen) {       // 退出全屏
    
                    if (document.exitFullscreen) {
    
                        document.exitFullscreen();
    
                    } else if (document.webkitCancelFullScreen) {
    
                        document.webkitCancelFullScreen();
    
                    } else if (document.mozCancelFullScreen) {
    
                        document.mozCancelFullScreen();
    
                    } else if (document.msExitFullscreen) {
    
                        document.msExitFullscreen();
    
                    }
    
                } else {        // 进入全屏
    
                    if (fullarea.requestFullscreen) {
    
                        fullarea.requestFullscreen();
    
                    } else if (fullarea.webkitRequestFullScreen) {
    
                        fullarea.webkitRequestFullScreen();
    
                    } else if (fullarea.mozRequestFullScreen) {
    
                        fullarea.mozRequestFullScreen();
    
                    } else if (fullarea.msRequestFullscreen) {
    
                        // IE11
    
                        fullarea.msRequestFullscreen();
    
                    }
    
                }
    
                fullscreen = !fullscreen;
    
            })
    
        </script>
    
    </html>
  • 相关阅读:
    AFNetworking使用总结
    使用Attiny 85开发板制作BadUSB
    C# 按指定数量从前面或者后面删除字符串
    C# 获取打印机列表
    【解决】该任务映像已损坏或已篡改。(异常来自HRESULT:0x80041321)
    PowerShell 解锁使用浏览器下载的文件
    C#使用HttpHelper万能框架,重启路由器
    【解决】应用程序无法正常启动(0xc000007b)。请单击“确定”关闭应用程序。
    Windows 7 IE11 F12 不能正常使用
    HTML5 图片上传预览
  • 原文地址:https://www.cnblogs.com/weifeng123/p/11026697.html
Copyright © 2020-2023  润新知