[html] HTML5如何监听video的全屏和退出全屏?
[html] HTML5如何监听video的全屏和退出全屏?
监听fullscreenchange事件
document.addEventListener('fullscreenchange', (event) => {
// document.fullscreenElement will point to the element that
// is in fullscreen mode if there is one. If there isn't one,
// the value of the property is null.
if (document.fullscreenElement) {
console.log(`Element: ${document.fullscreenElement.id} entered full-screen mode.`);
} else {
console.log('Leaving full-screen mode.');
}
});
个人简介
我是歌谣,欢迎和大家一起交流前后端知识。放弃很容易,
但坚持一定很酷。欢迎大家一起讨论