Bootbox 对 "ok" 和 "cancel" 回调做同样的事情。它也对提示做同样的事情

Bootbox does the same for "ok" and "cancel" callback. It does the same for prompt as well

Bootbox 关闭并停留在同一页面上。它应该重定向到另一个页面 onClick 和 "ok" 之后。它是一个 MVC 应用程序,并在单击时重定向到索引操作。相同的代码适用于传统的 Jquery 确认框。

$('.navbar, .navv').click(function(e) {
                e.preventDefault();

if(bootbox.confirm("Are you sure you want to leave the page!",
    function (result) {
        if (result === true) {
            return true; //should redirect to the Home page
        } else {
            return false; //Should stay in the same page
        }
    }));
});

仅当 true.

时,才移除 bootbox.confirm 和 return 周围的 if 循环
$('.navv').click(function(e) {
    e.preventDefault();
    bootbox.confirm("Are you sure you want to leave the page!",
    function (result) {        
        if(result) {
        window.open($('.navv').attr('href'));
      };
  });
});

单击此 link 观看演示。 https://jsfiddle.net/y3o8gamp/

请检查结果值,如果为 null == 单击了取消按钮,则它是空字符串 '' 带有空注释框的确定按钮被单击。

这对我有用。