How to Check whether a user clicked 'Ok' or 'Cancel' while using Confirm() function?
if (confirm('Are You Sure?')){
window.location = "http://www.google.com/";
}else{
alert("You are not redirected.")
}
You need to get the return value of confirm
, and then decide what to do next.
var answer = confirm('Are You Sure');
if (answer) {
//...
} else {
//...
}