开发者

Is there a way to add error checking to a stylesheet background image loader in Javascript?

开发者 https://www.devze.com 2023-01-13 07:37 出处:网络
I\'m using a background image in a di开发者_如何学JAVAv and want to have the div behave differently depending on whether the image loads or not.

I'm using a background image in a di开发者_如何学JAVAv 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?


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.

0

精彩评论

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