Last active
December 25, 2015 14:19
-
-
Save winwu/6990658 to your computer and use it in GitHub Desktop.
403 圖片偵測
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 () { | |
$('img').bind('load readystatechage error', function (e) { | |
//綁定 load, readystatechage error三個事件, | |
//不過只有error在這裡會用到 :P | |
var e = e.type; | |
switch(e){ | |
case 'error': | |
console.log('抓不到圖'); | |
$(this).attr('src','/images/no_img.png'); | |
break; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment