Search code examples
javascripthtmlimageonerror

How can I get an <img> element to re-evaluate its onerror?


I have an element with an onerror attribute that sets it to an image if its src is not found. This works great, but I want that onerror logic to be re-evaluated when the image's src is modified via javascript.

How can I do this?


Solution

  • obj.onerror() <--that should do it


    Scratch that

    It does it automatically: http://jsfiddle.net/FsFmf/ (tested in Chrome 13)