Replace broken twitter images with javascript?
In most cases you can replace a broken image开发者_JAVA百科 with some code that looks like this:
<img src="image.jpg" onerror="this.onerror=null;this.src='default.jpg'">
However, it doesn't seem to work with broken twitter profile images like this:
http://a1.twimg.com/profile_images/52087244/Photo_26.jpg
Is this because it is returning 403 instead of 404? Is there any way to fix this?
If onerror isn't working, you could try attaching a function to onload which does some checks to see if the image is acceptable (maybe testing width/height/src) and tries another if that doesn't work...
精彩评论