jQuery: Check if an image succesfully loads 

$(function(){

//prevent image cache
$('#a_img').attr('src',$('#a_img').attr('src')+'?rand='+Math.floor(Math.random()*10000));

//check for loading errors
$('#a_img').load().error(function(){

/* Legacy support kicking in */
var LegacyImg='http://www.example.com/dbimages/tag/h1/img_name.jpeg';
$('#a_img').attr('src',LegacyImg);

});

})


Comments
Comments are not available for this entry.
2024 By Angel Cool