You can do this with AJAX. You create an ajax call to this url and depending on the answer you know if the url exists, has errors or not. An example would look like this:
function verificar(url, cb) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) cb(true);
else cb(false);
};
request.onerror = function() {
cb(false);
};
request.send();
}
var links = document.querySelectorAll('a');
for (var i = 0; i < links.length; i++) {
links[i].addEventListener('click', verificador(links[i]))
}
function verificador(el) {
return function(e) {
e.preventDefault();
var url = e.target.href;
var status = verificar(url, function(sucesso){
alert('Essa página ' + (sucesso ? 'existe!' : 'não existe :('));
});
}
}
jsFiddle: link