我使用jQuery插件全屏https://github.com/martinaglv/jQuery-FullScreen 我的代码:HTML5全屏API逃生按钮事件
$('#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”按钮。我需要在按下这个按钮后运行一些功能,任何想法如何完成?
谢谢, Kuzzy。
(-1)加入jQuery的事件|| http://stackoverflow.com/questions/3369593/how-to-detect-escape-key-press-with-javascript || http://stackoverflow.com/questions/1160008/which-keycode-for-escape-key-with-jquery || http://stackoverflow.com/questions/9090821/is-there-any-way-in-jquery-cluetip-to-have-the-escape-key-close-a-sticky-tooltip || http://stackoverflow.com/questions/8635463/jquerys-autocomplete-customize-behavior-of-escape-key-press || http://stackoverflow.com/questions/6415299/javascript-execute-onclick-of-esc-key || http://stackoverflow.com/questions/7163493/jquery-datepicker-on-esc-key-event – Joonas 2012-03-08 08:16:02
@洛莱罗它不能在全屏模式下工作。例如$(document).keyup(function(e){if(e.keyCode == 27){alert('escape')} // esc \t});如果只按“Esc”即可使用,但在取消全屏时不起作用! – Kuzzy 2012-03-08 08:28:50
http://jsfiddle.net/lollero/mehTv/ – Joonas 2012-03-08 08:41:12