我在嘗試將全屏功能添加到我的應用中的某個元素時出現問題。HTML javascript fullscreen
我基本上做這樣的事情:
var launchFullScreen = function (element) {
if(element.requestFullScreen) {
element.requestFullScreen();
}
else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
}
else if(element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
}
};
var cancelFullscreen = function() {
if(document.cancelFullScreen) {
document.cancelFullScreen();
}
else if(document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
else if(document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
};
$("#view").on("keypress", function(event){
if(event.which == 27){
cancelFullscreen();
}
});
$("#view").on("click", function(event){
console.log("view clicked");
launchFullScreen($("#view"));
});
我不明白我在做什麼錯。有什麼建議麼?
退房這個庫https://github.com/sindresorhus/screenfull.js/ –