代码:
<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"
});
关于javascript - 无法使用甜蜜警报单击“确定”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37495916/