SweetAlert确认重定向

时间:2016-06-20 11:16:33

标签: javascript jquery alert sweetalert

用户按删除然后再次按 ok ,我就可以使用此功能重置游戏

function confirmReset() {
  swal({   
          title: "Are you sure you want to reset your game?",   text: "You will not be able to recover your game!",
           type: "warning",   
           showCancelButton: true,   
           confirmButtonColor: "#DD6B55",   
           confirmButtonText: "Yes, delete it!",   
           closeOnConfirm: false 
         }, function(){   
          swal("Deleted!", "Your imaginary file has been deleted.", "success"), 
            function(){
              window.location.href = "includes/php/reset.php?naam=<?php echo $naam ?>";
            }
      });
}

at,但是如果我在之后使用第二个函数,那么用户会提示确定以及它不会触发window.location.href

1 个答案:

答案 0 :(得分:2)

试试这段代码: -

function confirmReset() {
  swal({   
          title: "Are you sure you want to reset your game?",   text: "You will not be able to recover your game!",
           type: "warning",   
           showCancelButton: true,   
           confirmButtonColor: "#DD6B55",   
           confirmButtonText: "Yes, delete it!",   
           closeOnConfirm: false 
         }, function(){   
            swal({
                title: "Deleted!",
                text: "Your imaginary file has been deleted.",
                type: "success",
                //timer: 3000
            }, 
            function(){
              window.location.href = "/";
            })
      });
}