首页 > 网站 > WEB开发 > 正文

js控制浏览器全屏

2024-04-27 15:16:27
字体:
来源:转载
供稿:网友
var fullscreen = { full: function () {//全屏 var elem = document.documentElement; if (elem.webkitRequestFullScreen) { elem.webkitRequestFullScreen(); } else if (elem.mozRequestFullScreen) { elem.mozRequestFullScreen(); } else if (elem.requestFullScreen) { elem.requestFullscreen(); } else { alert("浏览器不支持全屏API或已被禁用") } }, exit: function () {//取消全屏 var elem = document.documentElement; if (elem.webkitCancelFullScreen) { elem.webkitCancelFullScreen(); } else if (elem.mozCancelFullScreen) { elem.mozCancelFullScreen(); } else if (elem.cancelFullScreen) { elem.cancelFullScreen(); } else if (elem.exitFullscreen) { elem.exitFullscreen(); } else { alert("浏览器不支持全屏API或已被禁用") } } };
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表