Home  >  Q&A  >  body text

javascript - How to remove the small icon in the upper left corner when the image request fails?

How to remove the small icon in the upper left corner when the image request fails?

淡淡烟草味淡淡烟草味2680 days ago912

reply all(4)I'll reply

  • 黄舟

    黄舟2017-06-17 09:17:59

    If the request fails, please assign a default picture

    reply
    0
  • 阿神

    阿神2017-06-17 09:17:59

    Give a default image. If successful, the requested image will be used. If failed, the default image will be used.

    reply
    0
  • typecho

    typecho2017-06-17 09:17:59

    The one that cannot be removed will still exist even if the alt attribute is added. The suggestion is that when the image request fails, display a default image or a prompt image indicating that the request failed, such as:
    <img src='xxx' onerror="this.src='http://i1.buimg.com /1949/8c5e2086e458c12d.png'"/>
    Not much to say about the path, both absolute paths and relative paths are acceptable.

    reply
    0
  • 黄舟

    黄舟2017-06-17 09:17:59

    Call the error event of the image. If loading fails, a prompt or replacement image will be given

    reply
    0
  • Cancelreply