html5 video fullscreen,html - Is there a way to make HTML5 video fullscreen? - Stack Overflow

2020 answer

HTML 5 provides no way to make a video fullscreen, but the parallel Fullscreen API defines an API for elements to display themselves fullscreen.

This can be applied to any element, including videos.

Browser support is good, but Internet Explorer and Safari need prefixed versions.

An external demo is provided as Stack Snippet sandboxing rules break it.

One

Two

one

two

div {

width: 200px;

height: 200px;

}

#one { background: yellow; }

#two { background: pink; }

addEventListener("click", event => {

const btn = event.target;

if (btn.tagName.toLowerCase() !== "button") return;

const id = btn.textContent;

const div = document.getElementById(id);

if (div.requestFullscreen)

div.requestFullscreen();

else if (div.webkitRequestFullscreen)

div.webkitRequestFullscreen();

else if (div.msRequestFullScreen)

div.msRequestFullScreen();

});

2012 answer

HTML 5 provides no way to make a video fullscreen, but the parallel Fullscreen specification supplies the requestFullScreen method which allows arbitrary elements (including elements) to be made fullscreen.

2009 answer

Note: this has since been removed from the specification.

From the HTML5 spec (at the time of writing: June '09):

User agents should not provide a

public API to cause videos to be shown

full-screen. A script, combined with a

carefully crafted video file, could

trick the user into thinking a

system-modal dialog had been shown,

and prompt the user for a password.

There is also the danger of "mere"

annoyance, with pages launching

full-screen videos when links are

clicked or pages navigated. Instead,

user-agent specific interface features

may be provided to easily allow the

user to obtain a full-screen playback

mode.

Browsers may provide a user interface, but shouldn't provide a programmable one.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值