Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (48 sloc) 1.79 KB
<body onload="main();">
<button type="button" onclick="request1();">Full&gt;&gt;</button>
<span id="panel">
<button type="button" onclick="request2();">Full&gt;&gt;</button>
<button type="button" id="exitButton" onclick="exit();">&lt;&lt;Exit</button>
</span>
<script src="../fullscrn.js"></script>
<script>
var panel = document.getElementById("panel");
var exitButton = document.getElementById("exitButton");
Fullscreen.debugMode(true);// Enables debug log
function main() {
// Handle change event
document.addEventListener("fullscreenchange",
function() {
var fse = document.fullscreenElement;
console.log("FULLSCREEN CHANGE: " +
((fse == null)? "(null)": "#" + fse.id));
});
// Handle error event
document.addEventListener("fullscreenerror",
function() { console.log("FULLSCREEN ERROR"); });
request1(); // This should be error
}
function request1() {
panel.requestFullscreen().then(function(){
console.log("request1 done.");
}).catch(function(err) {
console.error(err.message);
});
}
function request2() {
exitButton.requestFullscreen().then(function(){
console.log("request2 done.");
}).catch(function(err) {
console.error(err.message);
});
}
function exit() {
document.exitFullscreen()
.then(function(){
console.log("exit done.");
}).catch(function(err) {
console.error(err.message);
});
}
</script>
</body>