我在尝试将全屏功能添加到我的应用程序中的元素时遇到问题。
我基本上做这样的事情:
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"));
});
我看不出我做错了什么。有什么建议么?