单击确定或错误按钮后,我需要转到另一个页面...我的代码:
我使用 $(document) 因为我需要在页面加载时显示错误
请帮我一把;)
我认为这可以使用location.href = 'http://google.com'
来完成
这应该在确定/错误按钮单击处理程序中调用;
正如@technofreaky所说,您可以使用 JavaScript 进行重定向。 这是一个类似的例子: https :
我可以解决它:)
只使用 window.location.href .. 这里是代码:
$(document).ready(function() {
swal({
title: "Error",
text: "wrong user or password",
type: "error"
},
function(){
window.location.href = 'login.html';
});
});
谢谢你帮我
@fabianchoxD 干得好!
我需要在甜蜜警报中绑定一个 html 页面。 这样当我的甜蜜警报触发时,它应该在其正文中显示 html 页面。
当用户尝试使用 SweetAlert 关闭浏览器/选项卡时,我该如何发出警报? 请帮帮我..
@fabianchoxD谢谢,它有效。
任何人都知道点击使用persistant()
函数生成的OK
按钮时触发的回调函数/事件吗?
Alert::success('Success Message', 'Optional Title')->persistent("Ok");
@fabianchoxD感谢您的解决方案,但它对我不起作用。 我能够像这样解决这个问题:
swal({
title: "成功!",
文本:response.scriptstatus,
类型:“成功”
}).那么(函数(){
// 重定向用户
window.location.href = "new_url.html";
console.log('确定按钮被点击。');
});
@cnchg非常感谢,这对我
如果您的模态中还有一个“取消”按钮,您需要确认确实按下了“确定”按钮:
swal({...}).then(okay => {
if (okay) {
window.location.href = "...";
}
});
swal({
icon: "error",
title: "¡Error!",
showConfirmButton: true,
confirmButtonText: "Cerrar",
closeOnConfirm: false
}). then(function(result){
window.location = "WEREYOUWANTTOGO";
})
这是我对这个问题的解决方案!
函数 MessageWarning($message,$text,$icon,$sure,$url){
回声”
swal({
title:\"$mesaj\",
text:'$text',
icon:'$icon',
button:'Kapat'
});
";
header("Refresh: $sure; url=$url");
//location.href = 'http://www.alokatalog.com/'
//$gidecekSiteAdres= header('location:'.$_SERVER['HTTP_REFERER']);
}
MesajUyari("Proje Oluşturma Başarılı","Yönlendiriliyorsunuz
Lütfen Bekleyin","success",3,"Sayfa.php");/
@fabianchoxD感谢您的解决方案,但它对我不起作用。 我能够像这样解决这个问题:
swal({
title: "成功!",
文本:response.scriptstatus,
类型:“成功”
}).那么(函数(){
// 重定向用户
window.location.href = "new_url.html";
console.log('确定按钮被点击。');
});
谢谢!! 有效!!
我的是直接重定向到页面,甚至没有显示警报消息。 正在使用 Chrome。
swal({
title: "App",
text: "Error: Invalid Credentials, try again !",
icon: "error",
closeOnConfirm: false
}).then(
function () {
window.location.href = 'index.html';
}
);
嗨,我试图让 swal 在 5 秒后消失,所以我放了一个timer: 5000
但是当计时器完成后,即使用户没有点击按钮,它也会转到另一个页面。 如果用户没有单击 swal 上的按钮,我希望他留在页面上。 这是我的代码:
Swal.fire({
html: "Your tip has been published.",
icon: 'warning',
showCancelButton: false,
confirmButtonText: "See tip",
timer: 5000,
customClass: {
container: 'custom-alert',
popup: 'published-tip',
actions: 'actions-btn'
},
}).then(function() {
window.location = "/" + data.username;
});
最有用的评论
我可以解决它:)
只使用 window.location.href .. 这里是代码:
});
谢谢你帮我