开发者

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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜