【问题标题】:Back Button event返回按钮事件
【发布时间】:2015-10-15 17:15:20
【问题描述】:

我为我的照片制作了一个 html 页面。 单击某个区域时,会出现灯箱类型的功能。所以基本上页面的一部分是不可见的,然后出现在屏幕中间。 如果有人想要,我有一个关闭按钮可以摆脱它,还有 esc 按钮。

但是,尤其是在手机上,每个人都会点击手机后退按钮。所以我试图为后退按钮分配一个事件,而不是“返回上一页”只是“摆脱灯箱”。

这可能吗?

非常感谢, 埃利亚斯

【问题讨论】:

标签: html events button back


【解决方案1】:

有点笨拙但是……

window.onbeforeunload = function() { 
    if (LiteBoxOpen) {
        var r = confirm("Do you wish to leave the page? Press no to just close image");
        if (r == true) {
            return true;
        } 
        closeLiteBox(); // what ever is the function to close your litebox
        return false;
     }
} };

由于您不想删除用户历史记录,因此大多数用户都讨厌这样做。但你可以。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-26
    相关资源
    最近更新 更多