DIV全屏

作者: deast | 来源:发表于2020-07-06 11:58 被阅读0次

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

    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();
    }
    }

    相关文章

      网友评论

          本文标题:DIV全屏

          本文链接:https://www.haomeiwen.com/subject/thswqktx.html