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

  • Home
  • SEARCH
  • 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 8314261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:45:26+00:00 2026-06-08T20:45:26+00:00

In Chrome, Firefox, and Safari, I’m successfully using onError to remove images that didn’t

  • 0

In Chrome, Firefox, and Safari, I’m successfully using onError to remove images that didn’t load:

<img src="" onerror="jQuery(this).remove();" />

This doesn’t seem to work in Internet Explorer 9, but the second+ refresh of the page works fine and exactly like the other browsers. Is there a better way to remove img tags from the dom that didn’t load correctly in IE? It almost seems like IE is indefinitely waiting for images to load on the first page load?

  • 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-06-08T20:45:27+00:00Added an answer on June 8, 2026 at 8:45 pm

    I suspect that the error is being returned from the image before jQuery has loaded. This would cause the onerror handler to fire, but it would then fail.

    This doesn’t really need to be done with jQuery at all; you could use a regular Javascript to deal with it. Something like this should do the trick:

    this.parentNode.removeChild(this);
    

    That would be a direct replacement for the jQuery code you currently have. A similar amount of code and removes the need for jQuery, so removes any possible problem caused by loading sequence.

    It’s also worth pointing out that one of jQuery’s main reasons for existing is to help us get rid of the need for JS code embedded in the HTML like this, so seeing a jQuery call inside an HTML event like as per your original example just looks wrong.

    If you are going to use jQuery for this, don’t do it that that; use jquery’s proper event handling mechanisms. It would look like this:

    jQuery('img').error(function() {
        jQuery(this).remove();
    });
    

    This would be in a separate script tag, outside of your HTML.

    However, due to the issues of loading sequence, and the fact that your image loading errors will occur very early in the page load, I would suggest just going with the first solution. The jQuery solution might be more worthwhile if you have images loading dynamically after the main page load though.

    Hope that helps.

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

Sidebar

Related Questions

<img src=blah.png width=150 height=auto> In Firefox/Chrome/Safari, this image will display correctly. But in IE,
I am using the following test. In firefox/chrome/safari on my mac, panel1 renders above
unload function in jQuery works fine in Firefox but not in chrome and safari.
In chrome and safari, the following code works fine. in firefox , all platforms,
The following page looks good in Firefox, Safari, Chrome, IE6 and IE8... but it
I have 5 addons/extensions for Firefox, Chrome, Internet Explorer(IE), Opera, and Safari. How can
The following javascript opens a pop-up in Firefox, Safari, IE, and Google Chrome: window.open(http://google.com,
I have implemented the plugin by NPAPI for Firefox, Chrome, Safari, but there is
I have make a new dropdown navi in css . Chrome, firefox, safari is
On [my site][1] everything looks great in Firefox/Chrome/Safari (all the same) - but IE7,

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.