Hello Friends,
Sometimes we need to check, Is file is exist or not on particular location?
So, for this using below method we can check the file is exist or not !
Sometimes we need to check, Is file is exist or not on particular location?
So, for this using below method we can check the file is exist or not !
jQuery
<script type="text/javascript">
function imageExists(url, callback) {
var img = new Image();
img.onload = function() { callback(true); };
img.onerror = function() { callback(false); };
img.src = url;
}
function onload(id) /*This function will use while Mouseover event */
{
var imageUrl = "Image File URL";
imageExists(imageUrl, function(exists) {
if(exists==true){
/*Something Code here*/
}else{
/*Something Code here*/
}
});
}
</script>
function imageExists(url, callback) {
var img = new Image();
img.onload = function() { callback(true); };
img.onerror = function() { callback(false); };
img.src = url;
}
function onload(id) /*This function will use while Mouseover event */
{
var imageUrl = "Image File URL";
imageExists(imageUrl, function(exists) {
if(exists==true){
/*Something Code here*/
}else{
/*Something Code here*/
}
});
}
</script>
No comments:
Post a Comment