元素全屏的设置与监听

作者网站:http://hawkzz.com

设置全屏和退出全屏

 //全屏设置
    $('#fullScreen').on('click', function () {
        fullScreen();
    });
 //退出全屏
    $('#exitFullScreen').on('click', function () {
        exitFullScreen();
    });
 //进入全屏
function fullScreen() {
    var obj = document.getElementById('editMark');
    if (obj.requestFullScreen) {
        obj.requestFullScreen();
    } else if (obj.webkitRequestFullScreen) {
        obj.webkitRequestFullScreen();
    } else if (obj.msRequestFullScreen) {
        obj.msRequestFullScreen();
    } else if (obj.mozRequestFullScreen) {
        obj.mozRequestFullScreen();
    }
}

function exitFullScreen() {
    var obj = document.getElementById('editMark');
    if (document.exitFullscree) {
        document.exitFullscree();
    } else if (document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
    } else if (document.msExitFullscreen) {
        document.msExitFullscreen();
    } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    }
}

监听全屏事件

//监听全屏
    document.addEventListener('fullscreenchange', function () {
        if (document.fullscreenElement) {
          alert(1);
        } else {
          alert(2);
        }
    }, false);
    document.addEventListener('msfullscreenchange', function () {
        if (document.msFullscreenElement) {
           alert(1);
        } else {
           alert(2);
        }
    }, false);
    document.addEventListener('mozfullscreenchange', function () {
        if (document.mozFullScreen) {
            alert(1);
        } else {
            alert(2);
        }
    }, false);
    document.addEventListener('webkitfullscreenchange', function () {
        if (document.webkitIsFullScreen) {
           alert(1);
        } else {
             alert(2);
        }
    }, false);
时间: 2024-10-09 23:18:36

元素全屏的设置与监听的相关文章

安卓全屏的设置

有时安卓软件的开发需要设置全屏,首先介绍一个重要方法那就是requestWindowFeature(featrueId),它的功能是设置窗体标题的有无与样式.参数是Window类中定义的常量. 其中 FEATURE_CUSTOM_TITLE:自定义标题.当需要自定义标题时必须指定.如:标题是一个按钮时 this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); getWindow().setFeatureInt(Window.FEATURE_C

Android之如何设置键盘监听

5.设置键盘监听[以EditText为例] username.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // TODO Auto-generated method stub switch (keyCode) { case KeyEvent.KEYCODE_1: Toast.makeText(MainActivity.thi

DOM元素全屏显示解决方案(续)

前一篇中实现element全屏方案只适合单一的元素(元素里面不包含其他元素),但是如果里面有其他的元素呢?比如按钮之类的.如下图: 加上-webkit-full-screen{ width: 100%; height: 100%; } 之后全屏显示就变成: 1,button使用left和top来定位(左图).如果用bottom和right来定位(右图) 我们会发现element在全屏模式下尺寸和screen一样大了,但是element里面的子元素尺寸和位置设定还是原先的,这就为什么会出现上述情况

docker疑难解答 -- 设置远程服务监听

环境: ubuntu 16.04 tls docker version 17.05.0-ce ========================= 今天想要搭建一个多主机的集成docker环境,但是我最后发现设置docker远程服务监听的时候总是失败: Cannot connect to the Docker daemon at tcp://ip:port. Is the docker daemon running? 上网上搜了一下,都说是要修改/etc/default/docker中的DOCKE

DOM元素全屏显示解决方案

<script type="text/javascript"> function goFullscreen(id) { // Get the element that we want to take into fullscreen mode var element = document.getElementById(id); // These function will not exist in the browsers that don't support fullscr

Android隐藏标题设置全屏,设置背景

//隐藏标题 getWindow().requestFeature(Window.FEATURE_NO_TITLE); // 全屏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); // 设置背景 getWindow().setBackgroundDrawableResource(R.drawable.splash);

Spring boot设置启动监听端口

一.直接看代码: 1 @Controller 2 @EnableAutoConfiguration 3 @ComponentScan 4 public class CallMain extends SpringBootServletInitializer implements EmbeddedServletContainerCustomizer { 5 private final static Logger logger = LoggerFactory.getLogger(CallMain.cl

元素全屏居中(不变形)

窗口宽度大于高度,元素高度撑满窗口,宽度等比例缩放窗口高度大于宽度,元素宽度撑满窗口,高度等比例缩放 resize有3个参数: elem : 目标元素w : 元素宽度h : 元素高度 var resize = function(elem,w,h){ var dw = w, dh = h, cw = $(window).width(), ch = $(window).height(); var bw = cw > dw ? cw / dw : 1 / (dw / cw), bh = ch > d

(转)cocos2d-x 每帧动画的播放设置一个监听函数的做法

1 local cache = cc.AnimationCache:getInstance() 2 cache:addAnimations("animations-2.plist") 3 local animation = cache:getAnimation("dance_1") 4 animation:setDelayPerUnit(0.25) 5 animation:setRestoreOriginalFrame(true) 6 local aniamte =