Hi,
I've worked with JavaScript a lot so I understand its basic concepts, but I'm not a programmer.
I create and distribute a weekly comic strip and want to exhibit past strips on my website in a slide-show format that allows the viewer to manually proceed to the next slide when they have finished reading the current one.
The code found at the site listed below seemed to be close to what I wanted:
I copied and pasted the code into my editor and made two changes: (1) using .jpg instead of .gif, and (2) changing the folder name from "images" to "color_slides." I placed three image files named 1.jpg, 2.jpg, and 3.jpg into the folder named "color_slides."
My code is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Slideshow: Color Strips</title>
<SCRIPT LANGUAGE="JavaScript">
NewImg = new Array (
"color_strips/1.jpg",
"color_strips/2.jpg",
"color_strips/3.jpg"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;
//Time delay between Slides in milliseconds
var delay = 3000;
var lock = false;
var run;
function chgImg(direction) {
if (document.color_strips) {
ImgNum = ImgNum + direction;
if (ImgNum > ImgLength) {
ImgNum = 0;
}
if (ImgNum < 0) {
ImgNum = ImgLength;
}
document.slideshow.src = NewImg
;
}
}
function auto() {
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg(1)", delay);
}
}
</script>
</head>
<body>
<img src="color_strips/1.jpg" name="slideshow">
<table>
<tr>
<td align="right"><a href="javascript:chgImg(-1)">Previous</a></td>
<td align="center"><a href="javascript:auto()">Auto/Stop</a></td>
<td align="left"><a href="javascript:chgImg(1)">Next</a></td>
</tr>
</table>
</body>
</html>
__________________________________________________
When I try to run the code, the first strip appears, but the buttons don't work to go to the next strip.
Any help figuring out what I need to change will be greatly appreciated. Or if you have another JavaScript code that will do the job more elegantly, I'd love to see it.
Thanks!
Bill
I've worked with JavaScript a lot so I understand its basic concepts, but I'm not a programmer.
I create and distribute a weekly comic strip and want to exhibit past strips on my website in a slide-show format that allows the viewer to manually proceed to the next slide when they have finished reading the current one.
The code found at the site listed below seemed to be close to what I wanted:
I copied and pasted the code into my editor and made two changes: (1) using .jpg instead of .gif, and (2) changing the folder name from "images" to "color_slides." I placed three image files named 1.jpg, 2.jpg, and 3.jpg into the folder named "color_slides."
My code is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Slideshow: Color Strips</title>
<SCRIPT LANGUAGE="JavaScript">
NewImg = new Array (
"color_strips/1.jpg",
"color_strips/2.jpg",
"color_strips/3.jpg"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;
//Time delay between Slides in milliseconds
var delay = 3000;
var lock = false;
var run;
function chgImg(direction) {
if (document.color_strips) {
ImgNum = ImgNum + direction;
if (ImgNum > ImgLength) {
ImgNum = 0;
}
if (ImgNum < 0) {
ImgNum = ImgLength;
}
document.slideshow.src = NewImg
}
}
function auto() {
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg(1)", delay);
}
}
</script>
</head>
<body>
<img src="color_strips/1.jpg" name="slideshow">
<table>
<tr>
<td align="right"><a href="javascript:chgImg(-1)">Previous</a></td>
<td align="center"><a href="javascript:auto()">Auto/Stop</a></td>
<td align="left"><a href="javascript:chgImg(1)">Next</a></td>
</tr>
</table>
</body>
</html>
__________________________________________________
When I try to run the code, the first strip appears, but the buttons don't work to go to the next strip.
Any help figuring out what I need to change will be greatly appreciated. Or if you have another JavaScript code that will do the job more elegantly, I'd love to see it.
Thanks!
Bill