JS control full screen method
Record the js control full-screen method used in the project. It should be noted that each browser prohibits automatic full-screen js for user experience, which means that the following full-screen API needs to be triggered by the user interacting with the browser.
let element = document.documentElement
// 退出全屏
if (document.exitFullscreen) {
document.exitFullscreen()
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen()
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen()
} else if (document.msExitFullscreen) {
document.msExitFullscreen()
}
// 进入全屏
if (element.requestFullscreen) {
element.requestFullscreen()
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen()
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen()
} else if (element.msRequestFullscreen) { // IE11
element.msRequestFullscreen()
}