-
Notifications
You must be signed in to change notification settings - Fork 0
/
fullscreen-test.html
35 lines (32 loc) · 1.12 KB
/
fullscreen-test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Fullscreen Test</title>
</head>
<body>
<h1>Fullscreen Test</h1>
<img id="img" src="https://mdn.mozillademos.org/files/206/Canvas_backdrop.png" width="200" height="150" alt="" />
<button type="button" id="btnEnterFullScreen">Enter full screen</button>
<script src="fullscreen-polyfill.js"></script>
<script>
document.addEventListener("DOMContentLoaded",function(){
document.querySelector("#btnEnterFullScreen").addEventListener("click", function(event) {
console.log("fullscreenEnabled",document.fullscreenEnabled);
if(document.fullscreenEnabled){//fullscreen related attribute
var v=document.querySelector("img").requestFullscreen();//fullscreen related method
setTimeout(function(){
console.log("fullscreenElement",document.fullscreenElement);
},17);
}
});
document.onfullscreenchange=function(e){//fullscreen related event handler
console.log("fullscreenchange handler",e);
};
document.addEventListener("fullscreenchange",function(e){//fullscreen related event
console.log("fullscreenchange listener",e);
});
});
</script>
</body>
</html>