javascript - 无法使用甜蜜警报单击“确定”

标签 javascript sweetalert

代码:

<script>
    swal('Your ORDER has been placed Successfully!!!');
    window.location="index.php";
</script>

甜蜜警报工作正常并重定向到页面,但问题是警报不允许单击“确定”并重定向到页面。

有什么解决办法吗?

最佳答案

当sweetAlert关闭时,您的示例页面将被重定向到index.php。您是否单击“确定”或“取消”按钮并不重要。您必须使用sweetAlert的事件来控制“确定”点击事件。

尝试这个解决方案:

swal({
    title: "Are you sure?",
    text: "Some description",
    type: "warning",
    showCancelButton: true,
    confirmButtonColor: "#DD6B55",
    confirmButtonText: "Yes, please redirect the page!",
    closeOnConfirm: false
}, function() {
  location.href="http://google.com"
});

enter image description here

关于javascript - 无法使用甜蜜警报单击“确定”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37495916/

相关文章:

javascript - Mongoose 将两个查询合并为同一集合

javascript - IE 中的 onclick ="window.open"问题

javascript - SweetAlert2, .then() - 不立即更新 DOM

javascript - angularjs 表单验证显示空表单页面加载成功

javascript - 在 SweetAlert 中传递 ASP.NET 按钮单击事件

Javascript 计数器 - 如何添加更多值

javascript - 根据特定链接点击显示/隐藏 DIV

javascript - 如何检测 chrome 浏览器的 javascript 在 chrome 扩展应用程序中被禁用

javascript - 将javascript数组转换为具有相同键/值的对象

javascript - Sweet Alert JS库-修改动画速度