gpt4 book ai didi

javascript - SweetAlert 确认重定向

转载 作者:行者123 更新时间:2023-12-02 14:30:00 25 4
gpt4 key购买 nike

我有这个函数可以在用户按下删除然后再次按下确定后重置游戏。

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 ?>";
}
});
}

如果我在第二个swal('deleted'...等)的地方执行window.location.href,它就可以工作> 位于 ,但如果我在用户按下确定之后使用第二函数,它也不会触发window.location.href

最佳答案

试试这个代码:-

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 = "/";
})
});
}

关于javascript - SweetAlert 确认重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37921149/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com