<iframe src="https://b.example.com" allow="fullscreen"></iframe>Fullscreen API / notebook
Fullscreen API
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const video = document.getElementById("video");
// On pressing ENTER call toggleFullScreen method
document.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
toggleFullScreen(video);
}
});function toggleFullScreen(video) {
if (!document.fullscreenElement) {
// If the document is not in full screen mode
// make the video full screen
video.requestFullscreen();
} else {
// Otherwise exit the full screen
document.exitFullscreen?.();
}
}