退出全屏

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:大家可以微信添加订阅号“冷星学前端”,同步更新文章内容


前端荣耀
1.6k 声望745 粉丝

一个在程序猿修炼生涯中的修行者