I am trying this code but it gives me a DOM Exception. What I want it to get a true/false "answer" from the function using plain Javascript.
var url = 'http://www.google.com/';
function UrlExists(url)
{
var http = new XMLHttpRequest();
http.open('HEAD', url, false);
http.send();
return http.status!=404;
}
UrlExists(url);
I got this code from this SO answer, but as said I cannot get it working...
urlsupports CORS(html5rocks.com/en/tutorials/cors). Since many sites don't support CORS, client-side solution is not fool-proof.onerrorhandler for animgor possiblyobjecttag to see if you can retreive the status code. In the past I've abusediframes similarly but there are restrictions there (I've used it effectively with fire and forget calls and or when the iframe source explicitly calls back to the parent).