单击甜蜜警报上的确定按钮后如何重定向页面? [英] How to redirect page after click on Ok button on sweet alert?
本文介绍了单击甜蜜警报上的确定按钮后如何重定向页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在页面刷新后显示甜蜜警报,但是我必须单击确定按钮,我会在甜蜜警报上重定向页面。请帮助我。
I am able to display sweet alert after the page refresh but I have to click on Ok button which I am getting on sweet alert to redirect the page.Please help me in this.
<?php
echo '<script type="text/javascript">';
echo 'setTimeout(function () { swal("WOW!","Message!","success");';
echo '}, 1000);'
echo 'window.location.href = "index.php";';
echo '</script>';
?>
推荐答案
要指定回调函数,您必须使用object作为第一个参数,回调函数作为第二个参数。
To specify a callback function, you have to use an object as the first argument, and the callback function as the second argument.
echo '<script>
setTimeout(function() {
swal({
title: "Wow!",
text: "Message!",
type: "success"
}, function() {
window.location = "redirectURL";
});
}, 1000);
</script>';
这篇关于单击甜蜜警报上的确定按钮后如何重定向页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文