473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Optional Images

Hi All,
I m wondering if there is a way in which to display an image only if the file exists. I dont want an alternate text to be displayed, nor the image container (or whatever that is called). Thus, if the image file doesnt exist, there should be no trace.

I cannot use server side programming. Can you please suggest if it can be solved using client-side scripting ?

regards
parsifal
Jul 15 '06 #1
2 1567
iam_clint
1,208 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function checkimages() {
  3.     var y = document.images;
  4.     var imglength = 0;
  5.     for (i=0;i<y.length;i++)
  6.     {
  7.         imglength = (y[i].fileSize)*1;
  8.         if (imglength < 0) {
  9.             y[i].width = 0;
  10.             y[i].height = 0;
  11.         }
  12.     }
  13.  
  14. }
  15. </script>
  16. <body onload="checkimages();">
  17. <img src="raw.jpg">
  18. <img src="rock.jpg">
  19.  
basicly it sets the image width and height to 0 if it has no file size... you wont see it but it will still be in the source... this is as close as i could come to it... hopes this help you out... the image raw.jpg was an image i didn't have and rock was an image i did have and everything seemed to work ok.
Jul 15 '06 #2
singularly ingenious. It solves my case
Thanks a ton!!
Jul 16 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Heath | last post by:
Is it proper to center images in a <div> by using the text-align: center property? Or is there a better way?
8
by: George Adams | last post by:
I'm just starting to pick up some CSS knowledge after about 10 years of plain ol' HTML coding. I'm finding it easiest to learn CSS by example, so I'm following with interest the tricks I see done...
2
by: Julie | last post by:
Hi, I'm trying to change images on a website without reloading the whole page and use the following code to preload the images: var preloadFlag = false; function preloadImages() { if...
10
by: Not Me | last post by:
Hi, Is it possible to have a url as the link for an image in a form? I've tried but with no success, wondered if there's an alternative method? Cheers, Chris
5
by: Axel | last post by:
An Access 2000 question Hi is is possible to have (as a subform) a continous form with 0..n buttons which have different images in each row. (Personally I would have preferred a button...
4
by: Paul Keegstra | last post by:
Hello, I am working on a configurator application that needs to have a changing visual representation of the product being configured. I have a base image representing the 'core' requirements...
61
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the...
14
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
1
bilibytes
by: bilibytes | last post by:
hi, i was wondering if it is possible to make a SELECT query with some optional fields. i have "Object", "Info", "Image" Tables the object contains the id and name of objects, the info...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.