【问题标题】:How to see the actual image load error? (HTMLImageElement - onerror)如何查看实际的图像加载错误? (HTMLImageElement - 错误)
【发布时间】:2013-09-08 12:14:58
【问题描述】:

在 JavaScript 中,有没有办法查看给定 HTMLImageElement 加载失败的实际错误(无编解码器、损坏、未找到等...)? onerror 事件处理程序是否有任何参数可以帮助解决这个问题?

【问题讨论】:

标签: javascript dom


【解决方案1】:

好消息,it's totally possible.

不幸的是,错误事件没有正确冒泡。您还很可能需要在 JS 中设置图像的 src 以确保在引发错误事件之前绑定事件。

Here's some reading on image loading errors not bubbling.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-11
    • 2013-02-18
    • 2021-09-06
    • 1970-01-01
    • 2018-02-01
    • 2016-12-12
    • 2012-03-31
    相关资源
    最近更新 更多