页面在chrome 浏览器下document.fullscreenEnabled 返回undefined

页面在chrome 浏览器下document.fullscreenEnabled 返回undefined,但是其他页面返回值为true,可以确定的是浏览器肯定支持全屏,只是这个特殊页面下返回undefined,有人知道是什么原因吗,猜想是meta中写了什么特殊的配置,或者是有什么其他原因
原因已经找到了,因为是iframe标签,需要添加属性allowfullscreen="true",并且如果是iframe嵌套iframe,需要每个iframe标签都添加属性

第1个回答  2017-08-22
做全屏必须使用兼容代码,chrome的内核和其他游览器的内核是不一样的,不要单纯的使用一个document.fullscreenEnabled,而是要兼容性处理。给你参考如下的全屏显示代码,顺便送上退出全屏显示的。
//进入全屏
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozExitFullScreen) {
document.mozExitFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
//退出全屏
if (playVideo[0].requestFullscreen) {
playVideo[0].requestFullscreen();
} else if (playVideo[0].mozRequestFullScreen) {
playVideo[0].mozRequestFullScreen();
} else if (playVideo[0].webkitRequestFullscreen) {
playVideo[0].webkitRequestFullscreen();
} else if (playVideo[0].msRequestFullscreen) {
playVideo[0].msRequestFullscreen();
}本回答被提问者和网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网