I am working on a server-side database-driven website. When a user requests a certain page, the database forms the page and sends it. This page may include images that may currently not exist on the server. I have no way of knowing that ahead of time. What I am asking is this: Is thee any way I can tell the browser to display a pre-canned image (that I can provide) if the actual image is missing?
For example, if the page has the tag: <img src=”blabla.jpg” /> and when the browser requests the file blabla.jpg, the server responds with file-not-found. Then, the browser substitutes my pre-canned image, and the user never sees the ugly icon with the X in the middle.
Would something like this work:
<img src=”blabla.jpg” onError=”replace()” />
and the replace() function simply tells the browser:
document.images[4].src=”precanned.jpg”
or whatever?
However, I need a solution without changing the img tag, because that tag is created by the server and I have no access to it. Is there a way to capture the image onError event in the entire document and do the replace() thingy as above?
Thanks.