Why is Chrome's onerror event for the img element only fired once?

后端 未结 5 2024
时光说笑
时光说笑 2020-12-17 21:44

Why is Chrome is only calling the onerror event for the img element one time when all other browsers (IE7,8,9, FF, Opera, and Safari) all call it repeatedly?

Is ther

5条回答
  •  被撕碎了的回忆
    2020-12-17 22:09

    I've tried the ways metioned above, setAttribute('src', null) has a side effect, ie, add another request.

    Finally, I use

        setTimeout(function(){ imgElement.src = 'http://xxxx'; }, 0)
    

    , and this works!

    See the jsfiddle for example.

提交回复
热议问题