tags:

views:

15

answers:

1

I'm using a background image in a div and want to have the div behave differently depending on whether the image loads or not.

So, rather than doing img.onerror | img.onload I want to do style.backgroundImage.onerror or something along those lines

this isn't possible, is it?

+1  A: 

I don't think it is, but could you have an IMG tag loading the same image somewhere hidden on the page? If that one doesn't load, you can assume the background image hasn't loaded.

Tim
actually, that's exactly what I'm doing now, but the problem I'm running into (though it would be the same with the backgroundImage) is that since the callbacks are async by the time it is notified of the error condition, it has long since finished drawing the element.
Dr.Dredel
Try `visibility: hidden`
Justin Johnson