0

出于某种原因,以下代码对我不起作用,即使它看起来与我在网上找到的非常相似。我希望弹出一个甜蜜的警报,然后当用户单击确认按钮时,我希望脚本将它们发送回主页。然而,这只是显示了甜蜜的警报,并没有在关闭时重定向它们。另请注意 Sweet Alert 已正确安装。这是我的代码:

swal({
        title: 'Signed Up!',
        html: 'Thank you for registering',
        type: 'success',
        confirmButtonText: 'Got it!'
      }, function () {
         window.location.href = "index.php";
       }); 
4

1 回答 1

0
swal({
  title: 'Signed Up!',
  html: 'Thank you for registering',
  type: 'success',
  confirmButtonText: 'Got it!'
}).then(function () {
  window.location.href = "index.php";
}, function (dismiss) {
  // dismiss can be 'cancel', 'overlay',
  // 'close', and 'timer'
  if (dismiss === 'cancel') {
    window.location.href = "cancel.php";
  }
});

我没有对此进行测试,但文档说这会起作用。https://sweetalert2.github.io/

于 2017-09-29T03:47:48.463 回答