i'm working on a project and depending on what variables i send to a server file there can be different responses. one of them is a link and i want to check with jquery if the response is a link so i can redirect it..
i googled a bit and could only find how to redirect with jquery and this is not what i need.
this is my code at the moment and i need to find something for the response.message == URL
if(response.message == URL){
window.location.href = response.url;
}else{
$('#errormsg').html('<div class="alert alert-success">'+
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>'
+response.message+'</div>');
}
So does anyone know of a method to check if a string is an url? i would greatly appreciate your help :)