1 回答
TA贡献1744条经验 获得超4个赞
function fullscreen(){//全屏
var elem=document.body;
if(elem.webkitRequestFullScreen){
elem.webkitRequestFullScreen();
}else if(elem.mozRequestFullScreen){
elem.mozRequestFullScreen();
}else if(elem.requestFullScreen){
elem.requestFullscreen();
}else{
alert("浏览器不支持全屏API或已被禁用")
}
}
function exitFullscreen(){//退出全屏
var elem=document;
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或已被禁用")
}
}
以上代码 亲测有效 我之前用过的 算是比较全面的兼容 你自己看看 哪里有问题 你写的代码
试试这个:
添加回答
举报