Forums

This topic is locked

Somebody help...

Posted 28 Mar 2002 19:32:19
1
has voted
28 Mar 2002 19:32:19 Colin Miller posted:
The script below will detect if an image is missing and will simply not display anything, even a broken icon. Does anybody know how to modify this script to display a alternative default image? I am sure it must be fairly straightforward, trouble is I don't do much javaScript so any help would be welcome


<html>
  <head>
    <script language="JavaScript">
      function ImageLoadFailed() {
        window.event.srcElement.style.display = "None";
      }
    </script>
  </head>
  <body>
    <img
      src="localhost/images/nonexistingimage.gif"
      OnError="ImageLoadFailed()">
  </body>
</html>


Replies

Replied 29 Mar 2002 22:51:50
29 Mar 2002 22:51:50 Colin Miller replied:
OK, just in case anyone is looking for a solution to this, Brut over at 'Were here' has kindly posted the following (which works like a dream)


<html>
<head>
<script language="JavaScript">
function ImageLoadFailed(pic) {
pic.src = "images/incred.gif";
}
</script>
</head>
<body>
<img src="images/nonexistingimage.gif" OnError="ImageLoadFailed(this)">
</body>
</html>


Reply to this topic