jquery - HTML5 全屏 API 退出按钮事件

标签 jquery html jquery-plugins fullscreen

我正在使用 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/

相关文章:

html - 任意子字符串属性值选择器在 IE7 中不起作用

html - 标题窗口调整html大小

javascript - 使用 jQuery 将 ul 拆分为更多 ul

jquery - 表单展开时移动 DIV(过渡 CSS)

javascript - 如何更改此图片库的宽度?

jquery - jqgrid禁用默认客户端排序并手动处理

javascript - 在单击函数条件语句中调用时,函数值未定义

jquery - 使用 JQuery 在运行时更新数组值

javascript - 使用 jQuery 注册 adwords 转换

javascript - 选择下拉菜单时重定向到不同的 View ,然后单击按钮