Reputation: 31
I use "Sweetalerts" in my page. I've a static link which should redirect to "google.com". When i click on the link it shall show an alert message stating
if you click OK you will be redirected to google.com
As soon as one hits "OK" the redirection takes place.
The problem is that I'm able to see the alert message while clicking on the link, but the button doesn't work. It just closes the alert message instead of redirecting to the appropriated link.
Upvotes: 1
Views: 132
Reputation: 787
Have you tried the callback function of swal? Something like
swal({
title: "Are you sure?",
text: "If you click OK you will be redirected to google.com",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "OK",
closeOnConfirm: true},
function(){
window.location.href = "www.google.com";
});
If you post Code snippet, it will help other users to understand the issue.
Upvotes: 1
Reputation: 460
Swal Alert has an option for callback functions that run after an action.
swal({ title: "Are you sure?" },
function(){ window.location.href = "www.google.com"; });
Upvotes: 0
Reputation: 769
swal({
title: "Alert",
text: "Redirecting to google",
type: "success"
},
function(){
window.location.href = 'www.google.com';
});
Upvotes: 0