Problem specifying path for images in Javascript slideshow

B

busterama

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
 
W

web.dev

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'

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";
 
B

busterama

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.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
 
R

Randy Webb

Stephen Chalmers said the following on 10/7/2005 8:42 PM:
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.
 
S

Stephen Chalmers

Randy Webb said:
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.

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

busterama

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top