By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,598 Members | 1,897 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,598 IT Pros & Developers. It's quick & easy.

Problem specifying path for images in Javascript slideshow

P: n/a
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/misce...lide-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

Oct 7 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

buster...@gmail.com wrote:
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/misce...lide-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'
If directory with the images are a subdirectory of the current page,
then this is the correct one to use.
Pic[1] = '\images\interiors\2.jpg'
This one is an absolute path which starts from the root.

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

Is there something I'm missing here?
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";

TIA,
Buster


Oct 7 '05 #2

P: n/a
>> Is there something I'm missing here?
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";


The script is using that array to then set the property...
....
preLoad[i].src = Pic[i];
....
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

Oct 7 '05 #3

P: n/a
<bu*******@gmail.com> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com...
img src="images\interiors\Picture1a.jpg" name='SlideShow' width=350


That would be interpreted probably as: imagesinteriorsPicture1a.jpg

You can read about character escaping here:
http://developer.mozilla.org/en/docs...ers_in_Strings

Notwithstanding that, it's easier and always acceptable to specify paths
using forward slashes, as they do not need to be escaped.

--
S.C.


Oct 8 '05 #4

P: n/a
Stephen Chalmers said the following on 10/7/2005 8:42 PM:
<bu*******@gmail.com> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com...

img src="images\interiors\Picture1a.jpg" name='SlideShow' width=350

That would be interpreted probably as: imagesinteriorsPicture1a.jpg


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
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 8 '05 #5

P: n/a
Randy Webb <Hi************@aol.com> wrote in message news:2e********************@comcast.com...
Stephen Chalmers said the following on 10/7/2005 8:42 PM:
<bu*******@gmail.com> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com...

img src="images\interiors\Picture1a.jpg" name='SlideShow' width=350

That would be interpreted probably as: imagesinteriorsPicture1a.jpg


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.


Closer than you think; the i and P cannot be escaped, so they remain in place.

--
S.C.
Oct 8 '05 #6

P: n/a
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

Oct 10 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.