中易网

js检测全屏的办法

答案:2  悬赏:10  
解决时间 2021-03-14 21:16
function toggleFullScreen() {
if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // 非全屏状态
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.msRequestFullscreen) {
document.documentElement.msRequestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else { // 全屏状态
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}

附链接:https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
最佳答案
昂 , 我也碰到过这个问题 , 我写的时候代码量好像没有这么多 , 时间太长 , 记不住了.
全部回答
模糊了点
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
要上钢铁厂做什么毕业论文
我要做远程监控,是否要打电话给联通叫他给我
诚品品牌男装折扣店这个地址在什么地方,我要
今年想去大城市找工作,需要买个行李箱吗?会
我的弟弟长了一个耳仓,请问长耳仓的人,对身
hpv(6-11)结果1.54x10的6次方是什么意思
什么食物维生素b2含量高
按键精灵do while嵌套循环,x值没法复原,j循
我把我的手机自带的音乐播放器卸载了,然后用
摩托车年审得多少钱?
土承载力特征值确定方法有哪些?
我给不了你幸福但我不舍得你难过英文怎么说
琳琅满目罗家碾店在哪里啊,我有事要去这个地
现在去戈壁滩还能捡到玛瑙吗?谁最近去过说下
俄罗斯女性都要剃阴毛吗?
推荐资讯
北仑中国银行营业时间2016.6。29
一个女的和一个男的,比较能聊得来,能说明什
英文单词桑蚕丝被我就是要查找蚕丝被
如何设定播放器为默认的播放器?
我的手机wifi输入密码老是保存不连接怎么办
森力源商贸这个地址在什么地方,我要处理点事
广东粤剧院地址有知道的么?有点事想过去
arcgis数据 追加方法
大家看看我的希捷1T硬盘检测正常吗
汗液中含蛋白质吗?
我从Microsoft下载了Windows server 2008 r2
墨生斋书法培训中心二部在什么地方啊,我要过
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?