到目前为止我的代码如下:
swal({
title: 'Successfully Registered!',
text: "Do you want to go to the Log In page?",
type: 'success',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, send me there!'
},
function(){
window.location.href= "http://example.com";
}
);
由于某些原因,window.location.href无法工作,我尝试只使用location.href和if(isConfirm)等。
我该怎么办?
JSFiddle:
发布于 2017-04-26 22:07:03
下面是如何使用SweetAlert2实现的
Swal.fire({
title: 'Successfully Registered!',
text: 'Do you want to go to the Log In page?',
icon: 'success',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, send me there!'
}).then(function(result) {
if (result.value) {
location.assign("https://stackoverflow.com/")
}
});
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
SweetAlert2文档:https://sweetalert2.github.io/
请注意,SweetAlert2和SweetAlert是两个不同的项目。SweetAlert2使用ES6 Promises。
发布于 2019-02-24 07:47:09
这是我用来在点击时重定向的东西(OK)
<script>
sweetAlert({title: 'Error',text: 'Invalid OTP',type: 'error',onClose: function(){
window.location.href = 'https://google.com';
}});
</script>
https://stackoverflow.com/questions/43616916
复制相似问题