Created
October 15, 2013 12:25
-
-
Save winwu/6990804 to your computer and use it in GitHub Desktop.
403 圖片偵測加強版(ajax偵測)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function detect_if_image_loaded(){ | |
$('img').bind('error', function (e) { | |
var e = e.type; | |
switch(e){ | |
case 'error': | |
$(this).attr('src','/images/no_img.png'); | |
break; | |
} | |
}); | |
} | |
//第一次載入的時候不是ajax,所以先叫一次 | |
detect_if_image_loaded(); | |
$(document).ajaxStop(function() { | |
detect_if_image_loaded(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment