The following editor will bring you an example of setting up and monitoring element full screen, which has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor to take a look.
Set full screen and exit full screen
//全屏设置 $('#fullScreen').on('click', function () { fullScreen(); }); //退出全屏 $('#exitFullScreen').on('click', function () { exitFullScreen(); }); //进入全屏 function fullScreen() { var obj = document.getElementById('editMark'); if (obj.requestFullScreen) { obj.requestFullScreen(); } else if (obj.webkitRequestFullScreen) { obj.webkitRequestFullScreen(); } else if (obj.msRequestFullScreen) { obj.msRequestFullScreen(); } else if (obj.mozRequestFullScreen) { obj.mozRequestFullScreen(); } } function exitFullScreen() { var obj = document.getElementById('editMark'); if (document.exitFullscree) { document.exitFullscree(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } }
Listen to full screen events
//监听全屏 document.addEventListener('fullscreenchange', function () { if (document.fullscreenElement) { alert(1); } else { alert(2); } }, false); document.addEventListener('msfullscreenchange', function () { if (document.msFullscreenElement) { alert(1); } else { alert(2); } }, false); document.addEventListener('mozfullscreenchange', function () { if (document.mozFullScreen) { alert(1); } else { alert(2); } }, false); document.addEventListener('webkitfullscreenchange', function () { if (document.webkitIsFullScreen) { alert(1); } else { alert(2); } }, false);
The above is I compiled it for everyone, I hope it will be helpful to everyone in the future.
Related articles:
How to reset the idle state in vuex
Use Angular5 to implement server-side rendering practice
How to use advanced functions in JavaScript
How to implement chat function using nodejs
The above is the detailed content of How to set up and monitor using element full screen. For more information, please follow other related articles on the PHP Chinese website!