js控制全屏显示/退出全屏的方法

退出全屏

var exitFullScreen = function() {
    var e = document;
    e.exitFullscreen ? e.exitFullscreen() : e.mozCancelFullScreen ? e.mozCancelFullScreen() : e.webkitCancelFullScreen && e.webkitCancelFullScreen()
}

全屏显示

var openFullScreen = function() {
    var e = document.documentElement;
    if (e.requestFullscreen)
        e.requestFullscreen();
    else if (e.mozRequestFullScreen)
        e.mozRequestFullScreen();
    else if (e.webkitRequestFullScreen)
        e.webkitRequestFullScreen();
    else if ("undefined" != typeof window.ActiveXObject) {
        var t = new ActiveXObject("WScript.Shell");
        t && t.SendKeys("{F11}")
    }
}



PS:大家可以微信添加订阅号“冷星学前端”,同步更新文章内容

    原文作者:冷星
    原文地址: https://segmentfault.com/a/1190000009066717
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞