<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html" />
  <link rel="self" type="application/atom+xml" href="http://insideria.com/atom.xml" />
  <id>tag:insideria.com,2010://34/tag:www.insideria.com,2009://34.35754-</id>
  <updated>2010-07-21T10:09:36Z</updated>
  <title>Comments for jQuery Quickie - Broken Images (http://insideria.com/2009/03/jquery-quickie---broken-images.html)</title>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>
  <entry>
    <id>tag:www.insideria.com,2009://34.35754</id>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://blogs.oreilly.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=34/entry_id=35754" title="jQuery Quickie - Broken Images" />
    <published>2009-04-01T03:14:41Z</published>
    <updated>2009-04-01T03:14:41Z</updated>
    <title>jQuery Quickie - Broken Images</title>
    <summary>A simple jQuery technique to help fix broken images.</summary>
    <author>
      <name>Raymond Camden</name>
      <uri>http://www.coldfusionjedi.com</uri>
    </author>
    
    <category term="Blogs" />
    
    <content type="html" xml:lang="en" xml:base="http://insideria.com/">
      <![CDATA[Last week I discussed a simple jQuery method to handle images missing title tags. (See <a href="http://www.insideria.com/2009/03/jquery-quickie---images-and-al.html">jQuery Quickie - Images and Alt Tags</a>.) The code was rather simple. It used jQuery selectors to find images with missing title tags and either copy over the alt tag, or at least the file name. My thinking was that this could be useful for cases when you don't have control over the HTML. The client may be using a rich text editor that doesn't properly use the TITLE attribute.

<p/>

In the same vein of thought, what about <i>broken</i> images? Turns out the code to handle that is even simpler! Thanks go to <a href="http://www.cfsilence.com/blog/client/index.cfm">Todd Sharp</a> for sharing this with me. 

<p/>

First, let's begin with a simple page that has some hard coded HTML in it with a mix of good and broken images.

 <div class="acode" style="overflow: auto; padding: 10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>
&lt;<span class="category2">html</span>&gt;
	
&lt;head&gt;
&lt;title&gt;Image Test&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
	
&lt;div id="<span class="quote">content</span>"&gt;	
&lt;p&gt;
This is some content. Here is the first image...
&lt;/p&gt;
&lt;p&gt;
&lt;img src="<span class="quote">http://www.coldfusionjedi.com/images/raymond2008small.jpg</span>" title="<span class="quote">Raymond</span>"&gt;
&lt;/p&gt;
&lt;p&gt;
Another paragraph, first broken image...
&lt;/p&gt;
&lt;p&gt;
&lt;img src="<span class="quote">http://www.coldfusionjedi.com/pdfdpofopopf.jpb</span>"&gt;
&lt;/p&gt;
&lt;p&gt;
Third paragraph, will be a good image.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="<span class="quote">http://www.cflib.org/images/gravatarsample.jpg</span>"&gt;
&lt;/p&gt;
&lt;p&gt;
Last paragraph, another bad image.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="<span class="quote">http://www.coldfusionjedi.com/pdfdpofo.jpb</span>"&gt;	
&lt;/p&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/<span class="category2">html</span>&gt;</pre>
</code>

</div></div>

Nothing too complex here. Just a few paragraphs interspersed with images. The first and third image are valid. The second and fourth ones are not. Just to confirm they are indeed broken, check out the first <a href="http://www.coldfusionjedi.com/demos/badimage/test.html">demo</a>.

<p/>

So how do we fix it? Turns out rather easily. One of the events jQuery can listen out for is an error event. While not very obvious, an image with a bad url is considered an error. Maybe that is obvious, but it was a surprise to me. So to fix the broken images, we need a grand total of 3 lines of code:

<div class="acode" style="overflow: auto; padding: 10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>
$('<span class="quote">img</span>').error(<span class="category1">function</span>(){
 	$(<span class="category1">this</span>).attr('<span class="quote">src</span>', '<span class="quote">missing.jpg</span>');
});</pre>
</code>

</div></div>

In this snippet, the error event for all images tags is bound to a function that will update the image src to point to missing.jpg. Once again, I'm impressed by how useful jQuery can make tasks. You can view a demo of this <a href="http://www.coldfusionjedi.com/demos/badimage/test2.html">here</a>. You will notice the 2 broken images have been replaced. ]]>
      
    </content>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2056891</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2056891" />
    <title>Comment from Michael Evangelista on 2009-03-31</title>
    <author>
        <name>Michael Evangelista</name>
        <uri>http://www.miuaiga.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.miuaiga.com">
        <![CDATA[<p>Cool! I didn't know about jQuery error() - been doing it like this: </p>

<p></p>

<p>( gleaned a while back from <a href="http://www.robgonda.com/blog/index.cfm/2008/4/21/HTML-OnMissingImage">http://www.robgonda.com/blog/index.cfm/2008/4/21/HTML-OnMissingImage</a> )</p>

<p>But your jQuery method means it can be done globally... and it is jQuery, which means double cool points.</p>

<p>Just make sure your replacement image is really there, or you get a nasty browser meltdown in IE (not that I would ever do that... of course not... )</p>]]>
    </content>
    <published>2009-04-01T04:54:20Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2056892</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2056892" />
    <title>Comment from Raymond Camden on 2009-03-31</title>
    <author>
        <name>Raymond Camden</name>
        <uri>http://www.coldfusionjedi.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.coldfusionjedi.com">
        <![CDATA[<p>So credit goes to Todd and Rob. Definitely not 'my' idea, I'm just spreading the jQuery love. :)</p>]]>
    </content>
    <published>2009-04-01T04:58:53Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2056898</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2056898" />
    <title>Comment from Jeffrey Jose on 2009-04-01</title>
    <author>
        <name>Jeffrey Jose</name>
        <uri>http://twitter.com/jeffjose</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://twitter.com/jeffjose">
        <![CDATA[<p>Same here, didnt know there was an error function. Time to dig in more on that one. Thanks for sharing.</p>

<p>/j</p>]]>
    </content>
    <published>2009-04-01T07:07:01Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058358</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058358" />
    <title>Comment from Gary Funk on 2009-04-26</title>
    <author>
        <name>Gary Funk</name>
        <uri>http://www.fsoft.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.fsoft.com">
        <![CDATA[<p>This is great. One question though. Why does this work in FireFox and not IE. </p>]]>
    </content>
    <published>2009-04-26T16:20:31Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058359</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058359" />
    <title>Comment from Raymond Camden on 2009-04-26</title>
    <author>
        <name>Raymond Camden</name>
        <uri>http://www.coldfusionjedi.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.coldfusionjedi.com">
        <![CDATA[<p>Interesting. Not sure. Sorry - I had assumed such a simple thing would work fine in IE.</p>]]>
    </content>
    <published>2009-04-26T16:25:43Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058365</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058365" />
    <title>Comment from Gary Funk on 2009-04-26</title>
    <author>
        <name>Gary Funk</name>
        <uri>http://www.fsoft.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.fsoft.com">
        <![CDATA[<p>I put your code on my site and it works fine in IE. Just doesn't work in IE on your site. I wonder, in IE, what the URL is for the missing image. I used the FULL url to the image when I tried it. </p>]]>
    </content>
    <published>2009-04-26T20:45:04Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058366</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058366" />
    <title>Comment from Gary Funk on 2009-04-26</title>
    <author>
        <name>Gary Funk</name>
        <uri>http://www.fsoft.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.fsoft.com">
        <![CDATA[<p>I think I know why. It is looking for missing.jpg in the same directory that the missing image is in. Would you mind putting a different missing.jpg in your root directory. One that we can tell comes from the root directory?</p>

<p>Gary</p>]]>
    </content>
    <published>2009-04-26T20:58:53Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058368</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058368" />
    <title>Comment from Gary Funk on 2009-04-26</title>
    <author>
        <name>Gary Funk</name>
        <uri>http://www.fsoft.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.fsoft.com">
        <![CDATA[<p>One last item. I used: <a href="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js</a></p>

<p>instaed of the local code you used.</p>]]>
    </content>
    <published>2009-04-26T21:38:30Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058370</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058370" />
    <title>Comment from Gary Funk on 2009-04-26</title>
    <author>
        <name>Gary Funk</name>
        <uri>http://www.fsoft.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.fsoft.com">
        <![CDATA[<p>Ray,</p>

<p>Your local jquery.js is 1.3.1. It works with IE in 1.3.2.</p>]]>
    </content>
    <published>2009-04-26T21:50:09Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058376</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058376" />
    <title>Comment from Raymond Camden on 2009-04-26</title>
    <author>
        <name>Raymond Camden</name>
        <uri>http://www.coldfusionjedi.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.coldfusionjedi.com">
        <![CDATA[<p>Bam. You are the man. I don't know why I don't use the Google API version all of the time. Thanks Gary!</p>]]>
    </content>
    <published>2009-04-27T01:14:50Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058417</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058417" />
    <title>Comment from anthony on 2009-04-27</title>
    <author>
        <name>anthony</name>
        <uri>http://www.fojasaur.us</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.fojasaur.us">
        <![CDATA[<p>Ray,</p>

<p>This method doesn't work if the dom load event fires before the img error event.  I think that a better way of replacing images would be to wait for the window.onload event to fire, then check if any of the images are broken.<br />
<pre><br />
$(window).bind('load', function() {<br />
	$('img').each(function() {<br />
		if((typeof this.naturalWidth != "undefined" &&<br />
			this.naturalWidth == 0 ) <br />
			|| this.readyState == 'uninitialized' ) {<br />
			$(this).attr('src', 'missing.jpg');<br />
		}<br />
	});<br />
})<br />
</pre></p>

<p><br />
</p>]]>
    </content>
    <published>2009-04-27T16:21:39Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058418</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058418" />
    <title>Comment from Raymond Camden on 2009-04-27</title>
    <author>
        <name>Raymond Camden</name>
        <uri>http://www.coldfusionjedi.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.coldfusionjedi.com">
        <![CDATA[<p>Hmm, but I _am_ using $(document).ready - are you saying it needs to be window load instead?</p>]]>
    </content>
    <published>2009-04-27T16:25:27Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058420</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058420" />
    <title>Comment from anthony on 2009-04-27</title>
    <author>
        <name>anthony</name>
        <uri>http://www.fojasaur.us</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.fojasaur.us">
        <![CDATA[<p>No. The problem here is that if the image finishes its request and errors before the dom finishes loading, it's too late for jQuery to attach the onerror event.  So using the onerror event wont consistently work unless you attach the event inline.</p>

<p>To get around this, you can check to see if the images actually loaded instead.  $(document).ready happens once the dom is done, which could be before the images have finished loading, so that won't work reliably.  If we wait for everything to load (window.onload), then we can be sure that the image failed to load.</p>]]>
    </content>
    <published>2009-04-27T16:43:16Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2058442</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2058442" />
    <title>Comment from Raymond Camden on 2009-04-27</title>
    <author>
        <name>Raymond Camden</name>
        <uri>http://www.coldfusionjedi.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.coldfusionjedi.com">
        <![CDATA[<p>That makes sense. Thanks Anthony. Think I should write a follow up post that clearly demonstrates this?</p>]]>
    </content>
    <published>2009-04-27T21:15:07Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2059072</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2059072" />
    <title>Comment from Global Cooling on 2009-05-07</title>
    <author>
        <name>Global Cooling</name>
        <uri>http://www.bcooling.com.au</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.bcooling.com.au">
        <![CDATA[<p>Backing up what Raymond said....<br />
I wrote a script to resize and center image thumbnails within a container and I used the window.onload method instead of document.ready and I got more consistent results too, with document.ready it seems to jump the gun before all the images are fully loaded.</p>]]>
    </content>
    <published>2009-05-08T01:16:03Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2067392</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2067392" />
    <title>Comment from Scott Stroz on 2009-06-29</title>
    <author>
        <name>Scott Stroz</name>
        <uri>http://www.boyzoid.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.boyzoid.com">
        <![CDATA[<p>I cannot get this to work in IE 7 event when using updated jQuery and using window.onload.</p>]]>
    </content>
    <published>2009-06-29T13:18:18Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2067397</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2067397" />
    <title>Comment from Raymond Camden on 2009-06-29</title>
    <author>
        <name>Raymond Camden</name>
        <uri>http://www.coldfusionjedi.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.coldfusionjedi.com">
        <![CDATA[<p>Unfortunately I've only got IE8 not. Works fine there.</p>]]>
    </content>
    <published>2009-06-29T13:37:25Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2100030</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2100030" />
    <title>Comment from michael on 2009-09-15</title>
    <author>
        <name>michael</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Thanks for the code Ray.  However, if I put all the javascript at the bottom of your example (per best practice recommendation for performance), then your image src replacement doesn't work (i.e. doesn't get triggered).  Would you happen to know why?  Too late for img error event when placed at the bottom of html?</p>]]>
    </content>
    <published>2009-09-16T04:35:30Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2100048</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2100048" />
    <title>Comment from michael on 2009-09-15</title>
    <author>
        <name>michael</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>update: </p>

<p>I just tried using anthony's code above with $(window).bind('load')... and that works for me with all the javascript at the bottom of the html (thanks anthony!, and thanks Ray for the great post!).</p>]]>
    </content>
    <published>2009-09-16T04:48:17Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2100709</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2100709" />
    <title>Comment from Raymond Camden on 2009-09-16</title>
    <author>
        <name>Raymond Camden</name>
        <uri>http://www.coldfusionjedi.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.coldfusionjedi.com">
        <![CDATA[<p>Glad you got it, and thanks again Anthony for the fix.</p>]]>
    </content>
    <published>2009-09-16T11:54:37Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2400424</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2400424" />
    <title>Comment from bakee on 2010-03-25</title>
    <author>
        <name>bakee</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Thanks a lot. $(window).bind('load') worked for me</p>]]>
    </content>
    <published>2010-03-25T22:29:59Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2535139</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2535139" />
    <title>Comment from Nizar on 2010-05-23</title>
    <author>
        <name>Nizar</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Thanks for the code Ray. However, if I put all the javascript at the bottom of your example (per best practice recommendation for performance), then your image src replacement doesn't work (i.e. doesn't get triggered). Would you happen to know why? Too late for img error event when placed at the bottom of html?</p>

<p><a href="http://www.dd7.net">توبيكات</a></p>]]>
    </content>
    <published>2010-05-23T12:56:04Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2555310</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2555310" />
    <title>Comment from erwi on 2010-05-31</title>
    <author>
        <name>erwi</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p><br />
I have a web page that includes a bunch of images. Sometimes the image isn't available so a broken image is displayed in the clients browser.</p>

<p>How do I use jQuery to get the set of images, filter it to broken images then replace the src?</p>

<p>--I thought it would be easier to do this with Jquery, but It turned out much easier to just use a pure javascript solution. i.e the one provided by Prestaul<br />
javascript jquery html brokenimage<br />
flag</p>

<p><br />
function ImgError(source){<br />
    source.src = "/images/noimage.gif";<br />
    source.onerror = "";<br />
    return true;<br />
}</p>

<p></p>]]>
    </content>
    <published>2010-05-31T07:07:32Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35754-comment:2763138</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35754" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html"/>
    <link rel="alternate" type="text/html" href="http://insideria.com/2009/03/jquery-quickie---broken-images.html#comment-2763138" />
    <title>Comment from JOHN MATT on 2010-07-21</title>
    <author>
        <name>JOHN MATT</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>I'm really excited by this <a href="http://www.pass4sure.eu/Cisco/642-359.html">642-359</a>  simply for the direction it implies HTML layout is moving. I love Flex and the ease with which it lets me code up quick layouts, but sometimes it's over kill and I'd rather throw together a quick HTML page. Being able to use <a href="http://www.pass4sure.eu/Oracle/1z0-043.html">1z0-043</a> a coherent layout language to do that would make things so much easier....after MXML, most html layout code looks like way more effort than it's worth.I'm really excited by this simply for the direction <a href="http://www.pass4sure.eu/IBM/000-206.html">000-206</a> it implies HTML layout is moving. I love Flex and the ease with which it lets me code up quick layouts, but sometimes it's over kill and I'd rather throw together a quick HTML page. Being able to use a coherent layout language to do that would make things so <a href="http://www.pass4sure.eu/ISEB/BH0-006.html">BH0-006</a> much easier....after MXML, most html layout code looks like way more effort than it's worth.</p>]]>
    </content>
    <published>2010-07-21T10:09:32Z</published>
  </entry>

</feed
