function redirect() { var answer = confirm("Are you sure") if (answer){ window.location = "http://www.google.com"; }else{ window.location = "http://www.facebook.com"; } }