Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 JavaScript 中有没有办法查看给定HTMLImageElement加载失败的实际错误(无编解码器、损坏、未找到等)?事件处理程序是否onerror有任何参数可以帮助解决这个问题?
HTMLImageElement
onerror
好消息,完全有可能。
不幸的是,错误事件没有正确冒泡。您还很可能需要src在 JS 中设置图像,以确保在引发错误事件之前绑定事件。
src
这是一些关于不冒泡的图像加载错误的阅读。