zoukankan      html  css  js  c++  java
  • div的全屏与退出全屏

    div的全屏与退出全屏

    作用:将div全屏与退出全屏,一般播放器使用较多。

    html按钮:

    <button  onclick="showFull();">
                    全屏
                </button>
    <button onclick="delFull();"> 退出全屏 </button>

    js调用:

    function showFull(){
                   var full=document.getElementById("container");
                   launchIntoFullscreen(full);
                }
    
    function delFull() {
                    exitFullscreen();
                }

    全屏方法封装:

     function launchIntoFullscreen(element) {
                    if(element.requestFullscreen){
                        element.requestFullscreen();
                    }
                    else if(element.mozRequestFullScreen) {
                        element.mozRequestFullScreen();
                    }
                    else if(element.webkitRequestFullscreen) {
                        element.webkitRequestFullscreen();
                    }
                    else if(element.msRequestFullscreen) {
                        element.msRequestFullscreen();
                    }
                }

    退出全屏方法封装:

     function exitFullscreen() {
                    if(document.exitFullscreen) {
                        document.exitFullscreen();
                    } else if(document.mozCancelFullScreen) {
                        document.mozCancelFullScreen();
                    } else if(document.webkitExitFullscreen) {
                        document.webkitExitFullscreen();
                    }
                }

    参考自:http://blog.sina.com.cn/s/blog_1458577430102xn4r.html

  • 相关阅读:
    web http协议
    swoole udp
    swoole线程和进程
    SVN中trunk,branches,tags用法详解
    mysql外键使用和事物使用
    xml
    dedecms开启报错
    Django CBV方法装饰器
    Django Cookie和Session
    ORM基础5
  • 原文地址:https://www.cnblogs.com/s313139232/p/8371548.html
Copyright © 2011-2022 走看看