Problem specifying path for images in Javascript slideshow

Discussion in 'Javascript' started by busterama, Oct 7, 2005.

  1. busterama

    busterama Guest

    It's probably something simple, but I just can't find the solution.

    I'm using the javascript slideshow code at
    http://javascript.internet.com/miscellaneous/fading-slide-show.html
    for a slideshow on a webpage.

    Right now I'm prototyping the page on my computer, and eventually it'll
    move to the server.

    The script works fine when the images are in the same folder as the
    html file, but when I move the images off to sub-folders it doesn't
    find them.

    I've tried changing the values for filenames in the array to include
    the path, but it doesn't work.

    I've tried
    Pic[0] = 'images\interiors\1.jpg'
    Pic[1] = '\images\interiors\2.jpg'

    The "images\interiors\" path is just off the folder that the html files
    are stored in.

    Is there something I'm missing here?

    TIA,
    Buster
     
    busterama, Oct 7, 2005
    #1
    1. Advertisements

  2. busterama

    web.dev Guest

    If directory with the images are a subdirectory of the current page,
    then this is the correct one to use.
    This one is an absolute path which starts from the root.
    Yes, all you're doing is setting string values to arrays. What you
    wanted is more like the following:

    Pic[0].src = "images/interiors/1.jpg";
    ....
    Pic[n].src = "path/n.jpg";
     
    web.dev, Oct 7, 2005
    #2
    1. Advertisements

  3. busterama

    busterama Guest

    Is there something I'm missing here?
    wanted is more like the following:
    The script is using that array to then set the property...
    ....
    preLoad.src = Pic;
    ....
    img src="images\interiors\Picture1a.jpg" name='SlideShow' width=350
    (brackets removed just for post)
    ....

    Initially, the webpage loads the src that's manually set in the image
    take. Then, the javascript take over and changes the scr and reloads
    the image. It's when the Javascript takes over that it doesn't grab
    the picture.

    The javascript works fine if I just keep the images in the same folder.
    Weird.

    Buster

    Buster
     
    busterama, Oct 7, 2005
    #3
  4. That would be interpreted probably as: imagesinteriorsPicture1a.jpg

    You can read about character escaping here:
    http://developer.mozilla.org/en/doc...:Literals#Using_Special_Characters_in_Strings

    Notwithstanding that, it's easier and always acceptable to specify paths
    using forward slashes, as they do not need to be escaped.
     
    Stephen Chalmers, Oct 8, 2005
    #4
  5. busterama

    Randy Webb Guest

    Stephen Chalmers said the following on 10/7/2005 8:42 PM:
    Close but it would be imagesnteriorsicture1a.jpg without the first
    letter of interiors and Picture1a.

    The \ would escape the i and P and in the process they get lost.
     
    Randy Webb, Oct 8, 2005
    #5
  6. Closer than you think; the i and P cannot be escaped, so they remain in place.
     
    Stephen Chalmers, Oct 8, 2005
    #6
  7. busterama

    busterama Guest

    So this ended up working...
    Pic[0] = 'images\\interiors\\Picture1.jpg'
    Pic[1] = 'images\\interiors\\Picture2.jpg'
    Pic[2] = 'images\\interiors\\Picture3.jpg'
    Pic[3] = 'images\\interiors\\Picture4.jpg'
    Pic[4] = 'images\\interiors\\Picture5.jpg'
    Pic[5] = 'images\\interiors\\Picture6.jpg'

    Thanks for the help.

    Buster
     
    busterama, Oct 10, 2005
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.