They are:
1. Mizaru(See no evil)
2. Mikazaru(Hear no evil)
3. Mazaru(Speak no evil)
October 13, 2009
October 12, 2009
Function to check file exists in javascript
This function returns true if the file exists in the given URL. The below mentioned code is optimized to be use with Google Chrome also.
Instead of "return true, return false", "return 1, return 0" is used - this is because Google chrome avoids false and true statements.
function file_exists (url) {
// Returns true if filename exists
var req = this.window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
if (!req) {throw new Error('XMLHttpRequest not supported');}
// HEAD Results are usually shorter (faster) than GET
req.open('HEAD', url, false);
req.send(null);
if (req.status == 200){
return 1;
}
return 0;
}
Instead of "return true, return false", "return 1, return 0" is used - this is because Google chrome avoids false and true statements.
function file_exists (url) {
// Returns true if filename exists
var req = this.window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
if (!req) {throw new Error('XMLHttpRequest not supported');}
// HEAD Results are usually shorter (faster) than GET
req.open('HEAD', url, false);
req.send(null);
if (req.status == 200){
return 1;
}
return 0;
}
Subscribe to:
Posts (Atom)