how to aviod default break image icon if an image is not loaded from a file?
I have used a tag with attribute src="mydirectory/myimage.gif.
If开发者_StackOverflow社区 the image is not present in the directory , how can i avoid showing a default break image inside my img tag ?
this is present in chrome and I.E browsers but not in Firefox...
Any idea to avoid this ?
Thank You ...
A popular way to do it is to edit your web server.
for example, on apache, if you store all your images in a directory "http://host/images", and add a .htaccess file to that directory to redirect all 404s to serve a default blank image.
see here: Can Apache serve a default file instead of a 404? but you are serving an image instead of any kind of file.
There are other ways of doing it, for example, if you have access to a server side language (php, ruby) you can check if an image file exists on your server first, if not, serve a default image.
Or use the javascript method as mentioned by Pekka.
You can do it with your web server, server side / client side script.
I dont know if there's a way to do it with CSS, or other techniques, sure others will fill in.
Hope that is helpful.
精彩评论