title: Using JavaScript, how can I replace broken images with any other HTML data
body: <p>I provide a service, that help users to find location of pictures. My problem is that the pictures are stored on an other internal site, and my users needs to be connected to it to see the pictures (some may not have access, as my service provide other info). The built-in replacement (alt attribute of IMG) doesn't provide enough flexibility to inform the user of the corrective actions</p>
  
  <pre><code>&lt;div id=theDiv&gt;
      &lt;img src='http\internalSite\'+this.name+'.jpg'
      alt='Please connect to internalSite to see the picture '+this.name+'.jpg'&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I would like to improve the alt text, at least provide a link to 'internalSite' (or even better, load the connection page in an iFrame perhaps...). I found this to be impossible, so I would use onError attribute of IMG to replace what I have on the div</p>
  
  <p>But in fact, the image is placed here by script, so I think this is a bit silly and clearly not optimized
  how can my script detect that the picture is unavailable before, to decide what I do?</p>
  
  <p>in pseudo code:</p>
  
  <pre><code>if (isURLavailble(path)){
      loadPicture();
  } else {
      loadSomethingNiceToSayPicIsntAvailable() ;
  }
  </code></pre>
  
  <p>is it possible to define a working function (and of course cross-browser) that does isURLavailble(path); ?</p>