zoukankan      html  css  js  c++  java
  • js设置页面全屏

    html代码

    <!-- 全屏按钮 -->
        <img id="alarm-fullscreen-toggler" src="/public/index/images/open.png" alt="全屏按钮" />

    js代码

        // 设置全屏
    $('#alarm-fullscreen-toggler').on('click', function (e) {
        var element = document.documentElement;     // 返回 html dom 中的root 节点 <html>
        
        if(!$('body').hasClass('full-screen')) {
            $('body').addClass('full-screen');
            $('#alarm-fullscreen-toggler').addClass('active');
            // 判断浏览器设备类型
            if(element.requestFullscreen) {
                element.requestFullscreen();
            } else if (element.mozRequestFullScreen){   // 兼容火狐
                element.mozRequestFullScreen();
            } else if(element.webkitRequestFullscreen) {    // 兼容谷歌
                element.webkitRequestFullscreen();
            } else if (element.msRequestFullscreen) {   // 兼容IE
                element.msRequestFullscreen();
            }
            // 切换全屏按钮
            $('#alarm-fullscreen-toggler').attr('src','/public/index/images/close.png');
        } else {            // 退出全屏
            console.log(document);
            $('body').removeClass('full-screen');
            $('#alarm-fullscreen-toggler').removeClass('active');
            //  退出全屏
            if(document.exitFullscreen) {
                document.exitFullscreen();
            } else if (document.mozCancelFullScreen) {
                document.mozCancelFullScreen();
            } else if (document.webkitCancelFullScreen) {
                document.webkitCancelFullScreen();
            } else if (document.msExitFullscreen) {
                document.msExitFullscreen();
            }
            // 切换全屏按钮
            $('#alarm-fullscreen-toggler').attr('src','/public/index/images/open.png');
        }
    });
  • 相关阅读:
    Leetcode OJ: Rotate List
    Leetcode OJ: Reverse Words in a String
    Effective C++读书笔记
    word改变下划线与文字的距离
    sql 取出表中不重复的值
    Iso文件用utrliso怎么安装
    Spring注入aspectJ切面
    Spring中利用java注解声明切面
    Spring面向切面编程
    spring中部分异常
  • 原文地址:https://www.cnblogs.com/zxf100/p/10897992.html
Copyright © 2011-2022 走看看