Check if a file exits
Same domain only, ya know.
JavaScript
// same domain only
function fileExists( url ) {
oHttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
oHttp.open("HEAD", url, false);
oHttp.send();
return ( oHttp.status == 404 ) ? false : true;
}
if(fileExists("http://fiddle.jshell.net/img/logo.png")){
alert("fgdgh");
}else {
alert("hgdjfhjhf");
}