覆盖浏览器的window.confirm()方法 - 如何返回结果?

时间:2014-04-03 14:54:20

标签: javascript jquery twitter-bootstrap bootbox

我正在使用一个调用window.confirm的JavaScript库。默认的浏览器对话框非常难看,所以我想通过使用Bootbox库中的Bootstrap主题确认对话框来覆盖它。

我可以连接覆盖以显示Bootbox确认对话框,但无法根据用户选择将响应返回到自定义对话框中。在下面的例子中,我需要调用window ._(true | false)。

这是我最接近的。有什么想法吗?

        function consume_confirm() {
        if (window._confirm) return;

        window._confirm = window.confirm;

        window.confirm = function (message) {
            var answer;
            bootbox.confirm(message, function (result) {
                answer = result;
            });
            return answer;
        };
    }

0 个答案:

没有答案