The problem is it is impossible to make code wait. So what you need to do is cancel the original click and than call the code to navigate to the new page.
$(".alert").on('click', function(e){
e.preventDefault();
var href = this.href;
alertify.confirm("Are you sure?", function (e) {
if (e) {
window.location.href = href;
}
});
});