Firefox "onerror" Would Not Fire Even When Image Is Not Valid
I have a onerror handler on the image tag to handle switching when the remote image is not found. the problem is that for certain broken remote images, it does not work. http://a
Solution 1:
It is not a broken link.
The twimg.com
actually returns an image with the name of the url you requested.
just click your link to the image. It is not text what you are seeing, it is an image.
Update
Here is some code that works in all browsers.
It does some basic feature detection.
function handle( elem, img, state )
{
if ((typeof(elem.onerror) === 'function' && state === 'fail')
|| (elem.width === 0)
)
{
elem.src = img;
}
}
It uses both onload
and onerror
, but requires a function defined in javascript to handle the situation.
Post a Comment for "Firefox "onerror" Would Not Fire Even When Image Is Not Valid"