其他分享
首页 > 其他分享> > js全屏与退出全屏

js全屏与退出全屏

作者:互联网

function Fullscreen() {
    var elem = document.documentElement;
    // 判断浏览器设备类型
    if (elem.webkitRequestFullScreen) {  // 兼容谷歌
        elem.webkitRequestFullScreen();
    } else if (elem.mozRequestFullScreen) {  // 兼容火狐
        elem.mozRequestFullScreen();
    } else if (elem.requestFullscreen) {
        elem.requestFullscreen();
    } else if (element.msRequestFullscreen) {  // 兼容IE
        elem.msRequestFullscreen();
    } else {
        //浏览器不支持全屏API或已被禁用
    }
}


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

 

标签:msRequestFullscreen,elem,js,else,全屏,退出,document,兼容
来源: https://www.cnblogs.com/qq2806933146xiaobai/p/15140188.html