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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
body{
width:100%;
height:100%;
}
#divmonsite{
width:100vw;
height:100vh;
position: absolute;
left: 0;
top: 0;
background-color: gray;
z-index: 0;
}
#but{
width: 100px;
height: 50px;
position: absolute;
top: 10px;
left: 10px;
z-index: 1;
}
</style>
</head>
<body>
<div id="divmonsite"></div>
<input type="button" id="but" value="Fullscreen">
<script>
var elem = document.getElementById("divmonsite");
function openFullscreen() {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.mozRequestFullScreen) { /* Firefox */
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) { /* IE/Edge */
elem.msRequestFullscreen();
}
}
var but=document.getElementById("but");
but.addEventListener('click',openFullscreen);
</script>
</body>
</html> |
Partager