Failed to execute ‘requestFullscreen‘ on ‘Element‘

浏览器无法自启动全屏模式
报错信息:Failed to execute ‘requestFullscreen’ on ‘Element’: API can only be initiated by a user gesture.
翻译:无法在element上执行requestFullscreen方法,这个API只有用户主动行为才可以触发。

window.onload = () => {
 let element = document.documentElement 
if (element.requestFullscreen) { 
element.requestFullscreen()
} else if (element.msRequestFullscreen) { 
// 兼容ie element.msRequestFullscreen()
 } else if (element.mozRequestFullScreen) { 
// 兼容火狐 element.mozRequestFullScreen() 
} else if (element.webkitRequestFullscreen) { 
// 兼容chrome和safari element.webkitRequestFullscreen() 
}
} 
}
微信公众号
手机浏览(小程序)
1
分享到:
没有账号? 忘记密码?