• iframe全屏


    html:

    <div style="position: absolute;left:0;top: 0;">
    <input type="button" onclick="clickFun('baidu')" value="百度网全屏">
    <input type="button" onclick="clickFun('taobao')" value="淘宝网全屏">
    <input type="button" onclick="clickFun('qq')" value="腾讯网全屏">
    </div>
    <iframe id="baidu" name="baidu" frameborder="0" src="https://www.baidu.com/"></iframe>
    <iframe id="taobao" name="taobao" frameborder="0" src="https://www.taobao.com/"></iframe>
    <iframe id="qq" name="qq" frameborder="0" src="https://www.qq.com/"></iframe>

    css:

    *{
    margin: 0;
    padding: 0;
    }
    html,body{
    height: 100%;
    }
    #baidu{
    100%;
    height: calc(40% - 10px);
    border-bottom: 10px solid #c1c1c1;
    }
    #taobao{
    calc(40% - 10px);
    height: 60%;
    float: left;
    border-right: 10px solid #c1c1c1;
    }
    #qq{
    60%;
    height: 60%;
    background: #fff;
    }
    iframe{
    display: block;
    }

    js:

    function clickFun(id){
    launchFullscreen($("#"+id)[0]);

    }
    function launchFullscreen(element) {
    if (element.requestFullscreen) {
    element.requestFullscreen();
    } else if (element.mozRequestFullScreen) {
    element.mozRequestFullScreen();
    } else if (element.msRequestFullscreen) {
    element.msRequestFullscreen();
    } else if (element.webkitRequestFullscreen) {
    element.webkitRequestFullScreen();
    }
    }
    document.addEventListener('webkitfullscreenchange', function fullscreenChange() {
    if (document.fullscreenEnabled ||
    document.webkitIsFullScreen ||
    document.mozFullScreen ||
    document.msFullscreenElement) {
    console.log('enter fullscreen');
    } else {
    console.log('exit fullscreen');
    }
    }, false);
    function exitFullscreen() {
    if (document.exitFullscreen) {
    document.exitFullscreen();
    } else if (
    document.msExitFullscreen){
    document.msExitFullscreen();
    } else if (document.mozCancelFullScreen) {
    document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) {
    document.webkitExitFullscreen();
    }
    }

    另外:跨域情况下父iframe加属性allowfullscreen="true"即可

    <iframe name="baidu" allowfullscreen="true" frameborder="0" src="http://127.0.0.1:8833/baidu.html"></iframe>

  • 相关阅读:
    MT【38】与砝码有关的两个题
    MT【37】二次函数与整系数有关的题
    MT【36】反函数有关的一道题
    MT【35】用复数得到的两组恒等式
    MT【34】正余弦的正整数幂次快速表示成正余弦的线性组合
    MT【33】证明琴生不等式
    MT【32】内外圆(Apollonius Circle)的几何证明
    MT【31】傅里叶级数为背景的三角求和
    MT【30】椭圆的第二定义解题
    MT【29】介绍向量的外积及应用举例
  • 原文地址:https://www.cnblogs.com/onceweb/p/13743705.html
Copyright © 2020-2023  润新知