SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Evangelist goughb's Avatar
    Join Date
    Sep 2000
    Location
    Chicago
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Greetings,

    When asking for an image that is not available what is the value that gets stored in document.(image name) ? Is it null? Any thoughts.

    Sincerely,

    Brett

  2. #2
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by goughb
    Greetings,

    When asking for an image that is not available what is the value that gets stored in document.(image name) ? Is it null? Any thoughts.

    Sincerely,

    Brett
    The Image object doesn't have a Value property. It has a SRC property which is what your most likely thinking of. It should contain an emtpy string (""), since Javascript is supposed to initialize objects at creation.
    Wayne Luke
    ------------


  3. #3
    SitePoint Evangelist goughb's Avatar
    Join Date
    Sep 2000
    Location
    Chicago
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, what I am refering to is that I have a script to go out and grab an image sorta like a photo album and it just keeps grabbing the next image etc if the user hits the forward button. However, it would be nice to know when the image is not there. Otherwise it shows the little X and gets really messed up. Here is the URL
    http://www.uwplatt.edu/~sigeps/photo.html

    Sincerely,

    Brett

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Brett,

    Are you trying to test if an image exists?
    The following example should clarify things:

    <script language='javascript'>
    <!--
    var pic1;
    alert(document.images.pic1)
    if (document.images.pic1 == null)
    alert(1)
    else alert(0)
    //-->
    </script>

    If you place the above in a blank page the first alert will say "undefined". However the second will come up with "1", meaning that if you try to access an image that does not exist, the value returned will be null. This should also be true if you use the following syntax:
    alert(document.images[num]) and alert(document.images['name']) since the return value of an out of bounds array element (regardless of type) is null
    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •