View Full Version : Slideshow - location of image files

07-19-2010, 10:20 PM
Here is a simple slideshow with an on-off button. The images (7 defined) are numbered 01-07.jpg and in the same folder.

My question. How to call the images from a different folder with the script.

I can change the <img scr> HTML tag to include a directory where the images are but how do I tell the script?

Thanks in advance!

---page code below---

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<script type="text/javascript">
var Start = 1
var Timer3
function SlideShow()
if (document.all.ShowButton.value == "Stop Show") {
document.all.ShowButton.value = "Start Show"
} else {
document.all.ShowButton.value = "Stop Show"
Timer3 = setInterval("NextPic()" ,3000)
function NextPic()
Start += 1
if (Start > 7) {
Start = 1
document.all.Pic.src = "0" + Start + ".jpg"

<img id="Pic" src="01.jpg"></p>
<input id="ShowButton" type="button" value="Start Show" style="font-size:9pt"


Old Pedant
07-19-2010, 10:29 PM
Instead of

document.all.Pic.src = "0" + Start + ".jpg";

you just use

document.all.Pic.src = "yourImageDirectory/0" + Start + ".jpg";


But that code will *ONLY* work in MSIE. document.all is an obsolete mechanism left over from MSIE 4 days. MSIE 6 (and I think even 5) and beyond all support the modern standard:

document.getElementById("Pic").src = "yourImageDirectory/0" + Start + ".jpg";

If you see code still using document.all, you can be pretty sure it is ancient history code that should be avoided.

Old Pedant
07-19-2010, 10:30 PM
Actually, the fact that you are using
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
pretty much means you aren't going to work with old MSIE browsers, anyway. So why stick with document.all??

07-19-2010, 10:41 PM
That simple line is what I needed. This slide show is small but if large would be great to have all the images in their own directory.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum