RE: Missing Image Detect?
by "Charlton, Mark" <Mark.Charlton(at)sgcna.com>
|
| Date: |
Mon, 15 Jan 2001 17:22:29 -0500 |
| To: |
"'hwglister(at)mail.technicalcommunication.com'" <hwglister(at)mail.technicalcommunication.com> |
| Cc: |
"'hwg-techniques(at)hwg.org'" <hwg-techniques(at)hwg.org> |
| |
todo: View
Thread,
Original
|
|
Here is some code I probably got from someone on this list, (Thanks it's
great) :)
It's original job was to insert the contents of a text file into a page
during the ASP parsing. I have made a few changes and should test for the
presence of an image and return it if possible.
=============================
Dim filesystem
Set filesystem = Server.CreateObject("Scripting.FileSystemObject")
sub getImage(img_file)
Dim filepath
filepath = Server.mappath(img_file)
if filesystem.FileExists (filepath) then
Response.write "<img src='" & filepath & "' alt='Mag Cover'
height=YY width=XX>"
else
'
Response.write "<p>Sorry, The cover for the selected issue is not
currently available. </p>"
'
end if
end sub
================================
There is probably a way of doing it in JS by creating an image object and
trying to preload the image and testing for success, but I have no idea
exactly how you would do it, and it would undoubtably be slower and less
reliable.
Regards
Mark
-----Original Message-----
From: Imran Zaidi [mailto:hwglister(at)mail.technicalcommunication.com]
Sent: Monday, January 15, 2001 3:52 PM
To: hwg-techniques(at)hwg.org
Subject: Missing Image Detect?
Hi folks. Have a question....
I have a page in an ASP online magazine application that displays the cover
image of a magazine depending on the issue you select.
Question is, what do I do if the cover image doesn't exist?
Is there a way in either ASP or HTML or Javascript to detect that an image
doesn't exist, and then have the 'no cover image available' graphic appear
instead? This seems like something I'd expect the client to be able to
handle the logic for, so maybe Javascript?
Thanks!
Imran Zaidi
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA
This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.