我正在使用 jQuery 全屏插件 https://github.com/martinaglv/jQuery-FullScreen 我的代码:
$('#cancel-fullscreen').hide()
//View Fullscreen
$('#view-fullscreen').click(function(){
$('#container').css({'background': 'green'}).fullScreen();
$(this).hide();
$('#cancel-fullscreen').show();
return false;
});
//Cancel Fullscreen
$('#cancel-fullscreen').click(function(){
//I need this work when "Esc" or "F11" buttons pressed
$('#container').css({'background': 'red'}).fullScreen(); //If press "Esc" background still green..
$(this).hide();
$('#view-fullscreen').show();
return false;
});
效果很好,但我的设计中不需要“取消”按钮,全屏按“Esc”或“F11”按钮即可取消。按下这个按钮后我需要运行一些功能,有什么办法可以做到吗?
谢谢, 库兹。
最佳答案
决定从评论中收集这些内容。
你可以这样做。
(Jsfiddle 已更新,因为我不小心删除了评论中显示的内容)
http://jsfiddle.net/lollero/sxpam/
http://jsfiddle.net/lollero/sxpam/show/ - 此链接应用于测试实际功能。
//View Fullscreen
$('#view-fullscreen').click(function(){
$('#container').css({'background': 'green'}).fullScreen({
'callback' : function(fullScreen){
if ( !fullScreen ) {
// Canceled
$('#container').css({'background': 'red'});
}
}
});
$(this).hide();
return false;
});
关于jquery - HTML5 全屏 API 退出按钮事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9614556/