Fullscreen API 具有处理全屏 HTML 元素的方法和属性。
以全屏模式显示 <video> 元素:
/* Get the element you want to display in fullscreen */
var elem = document.getElementById("myvideo");
/* Execute the openFullscreen() function to open the video in fullscreen. Include prefixes for browsers that do not support the requestFullscreen property */
function openFullscreen() {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.webkitRequestFullscreen) { /* Safari */
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) { /* IE11 */
elem.msRequestFullscreen();
}
}
亲自试一试 »
Property/Method | Description |
---|---|
exitFullscreen() | Cancels the element in fullscreen mode |
fullscreenElement | Returns the element that is in full-screen mode, |
fullscreenEnabled() | Returns true if the document can be viewed in fullscreen mode |
requestFullscreen() | Opens an element in fullscreen mode |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!