Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7019897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:14:46+00:00 2026-05-27T23:14:46+00:00

An HTML <img> element has a boolean complete property, which is true if the

  • 0

An HTML <img> element has a boolean complete property, which is true if the image has successfully loaded (or if it hasn’t yet been assigned a src). It also has an onload event, which fires when the image successfully loads, and an onerror event, which fires when the image fails to load (e.g. due to a broken link, corrupt image, or offline network).

Now… what I want to know is if there is a property on an image element that denotes that the image has already failed to load. Assume that I cannot use the onerror event, because the script may only have access to the image after the event has fired. What we are looking for is a simple boolean lookup property like complete that says “the loading of this image was already attempted, and it failed”. (Which I don’t see in the spec, but I’m wondering if I’m missing something).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:14:47+00:00Added an answer on May 27, 2026 at 11:14 pm

    You can use naturalWidth and naturalHeight for a similar effect in almost all browsers (IE8 and below do not support this property). The naturalXX properties contain the original height/width of the image, before modifications through HTML/CSS attributes/styling. So if naturalWidth == 0, you know the image has failed to load.

    (Note that you can’t use the standard width or height properties, since those will return the size of the notfound placeholder image.)

    document.getElementById("image").naturalWidth ? "success" : "fail"
    

    If you’re just trying to change the not found placeholder image, there’s a nifty HTML solution for that:

    <object data="https://stackoverflow.com/does-not-exist.png">
      <img src="https://stackoverflow.com/content/img/so/logo.png">
    </object>
    

    fiddle: http://jsfiddle.net/K3dwX/1/

    PS: Potential solution for IE6+

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

html is <table> <tr> <td><img src=ex.jpg id=image class=edit name=n1></td> <td><img src=ex.jpg id=image class=edit name=n2></td>
I'm building a webpage which has an 'img' floated within a div as the
I am trying to disable a sortable element from sorting when it has been
I have to hide a td element in a tr which has 2 td
I am trying to get some JavaScript to programmatically adjust a HTML img tag's
I'm trying to display some large images with HTML img tags. At the moment
In my HTML pages I have text with img s. The top edge of
---HTML <div id=story> <div id=individual> <img src='uploads/1231924837Picture.png'/> <h2>2009-01-14</h2> <h1>Headline</h1> <p>stroy story etc stroy story
I need to process a HTML content and replace the IMG SRC value with
I'm loading HTML from an AJAX request, and some img tags in it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.