Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 引导框如何在href链接上重定向_Jquery_Html_Bootbox - Fatal编程技术网

Jquery 引导框如何在href链接上重定向

Jquery 引导框如何在href链接上重定向,jquery,html,bootbox,Jquery,Html,Bootbox,我是jquery和bootbox的新手,我想在确认的每个按钮警报中添加一个操作,所以如果选择的按钮是yes,那么我想在链接中重定向 例如 <script type="text/javascript"> $(function() { bootbox.confirm({ message: "click yes to redirect google", buttons: { confirm: { label: 'Yes', className:

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

<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>

$(函数(){
bootbox.confirm({
消息:“单击“是”重定向google”,
按钮:{
确认:{
标签:'是',
类名:“btn成功”
$(位置).attr('href',”http://www.google.com/");
},
取消:{
标签:‘否’,
类名:“btn危险”
}
},
回调:函数(结果){
log('这是在回调中记录的:'+结果);
}
});
});
我使用了
$(location.attr('href',”http://www.google.com/");但它不起作用


感谢文档中的示例

所以你可以用这个

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

只需使用
location.href=新值
。没有理由把它放在jQuery对象中。但是,您试图将其放入一个不正确的对象(
{}
)。bootbox可能有一些方法可以绑定单个按钮的回调,但不适用于location.href
    callback: function(result) {
        if (result === true) {
            location.href = 'http://www.google.com';
        }
    }