bootbox 如何在 href link 上重定向

bootbox how to redirect on href link

我是 jquery 和 bootbox 的新手,我想为确认的每个按钮警报添加一个动作,所以如果选择的按钮是,那么我想在 link 中重定向 例如

<script  type="text/javascript">
$(function() {

bootbox.confirm({
message: "click yes to redirect google",
buttons: {
    confirm: {
        label: 'Yes',
        className: 'btn-success'
        $(location).attr('href',"http://www.google.com/");

    },
    cancel: {
        label: 'No',
        className: 'btn-danger'
    }
},
callback: function (result) {
    console.log('This was logged in the callback: ' + result);
}
});
});
</script>

我用过$(location).attr('href',"http://www.google.com/");但没用

谢谢

文档中的示例。 http://bootboxjs.com/documentation.html#bb-confirm-dialog

bootbox.confirm({ 
    size: "small",
    message: "Are you sure?", 
    callback: function(result){ /* result is a boolean; true = OK, false = Cancel*/ }
})

所以你可以直接使用它

    callback: function(result) {
        if (result === true) {
            location.href = 'http://www.google.com';
        }
    }