Scribe
05-01-2003, 12:40 PM
I've been trying to get two instances of the same javascript to work on the same page. The script is a slideshow which displays a series of images.
I want to have each script display a different a set of images.
I've been able to get both working simultaneously but they are both displaying the same array. Eventually, they both reach for the same file and the scripts both hang.
I've tried naming the arrays differently within each script but it hasn't solved the problem.
The scripts are copied below. Any suggestions are gratefully appreciated. (Of course, it might not even be possible to do this but I figured I'd yell for help before I gave up.)
The page is at:
http://www.bobwallcontracting.com/sperber.htm
The main part of the script is below. There is also an onload command in the <body> tag and names attached to the <td> tag and <img> tags.
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin slideshow
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();
// to add more images, just continue
// the pattern, adding to the array below
Pic[0] = 'photos/sperber/exteriorSM.jpg'
Pic[1] = 'photos/sperber/entrance2SM.jpg'
Pic[2] = 'photos/sperber/doorSM.jpg'
Pic[3] = 'photos/sperber/upper_landingSM.jpg'
Pic[4] = 'photos/sperber/bedroom4SM.jpg'
// do not edit anything below this line
var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow() {
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin slideshow2
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array2();
// to add more images, just continue
// the pattern, adding to the array below
Pic[20] = 'photos/sperber/dock2SM.jpg'
Pic[21] = 'photos/sperber/dock3SM.jpg'
Pic[22] = 'photos/sperber/dock6SM.jpg'
Pic[23] = 'photos/sperber/exterior2SM.jpg'
Pic[24] = 'photos/sperber/baywindowsSM.jpg'
// do not edit anything below this line
var t;
var j = 20;
var p = Pic.length;
var preLoad = new Array2();
for (i = 20; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow2() {
if (document.all) {
document.images.SlideShow2.style.filter="blendTrans(duration=2)";
document.images.SlideShow2.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow2.filters.blendTrans.Apply();
}
document.images.SlideShow2.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow2.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 20;
t = setTimeout('runSlideShow2()', slideShowSpeed);
}
// End -->
</script>
I want to have each script display a different a set of images.
I've been able to get both working simultaneously but they are both displaying the same array. Eventually, they both reach for the same file and the scripts both hang.
I've tried naming the arrays differently within each script but it hasn't solved the problem.
The scripts are copied below. Any suggestions are gratefully appreciated. (Of course, it might not even be possible to do this but I figured I'd yell for help before I gave up.)
The page is at:
http://www.bobwallcontracting.com/sperber.htm
The main part of the script is below. There is also an onload command in the <body> tag and names attached to the <td> tag and <img> tags.
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin slideshow
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();
// to add more images, just continue
// the pattern, adding to the array below
Pic[0] = 'photos/sperber/exteriorSM.jpg'
Pic[1] = 'photos/sperber/entrance2SM.jpg'
Pic[2] = 'photos/sperber/doorSM.jpg'
Pic[3] = 'photos/sperber/upper_landingSM.jpg'
Pic[4] = 'photos/sperber/bedroom4SM.jpg'
// do not edit anything below this line
var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow() {
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin slideshow2
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array2();
// to add more images, just continue
// the pattern, adding to the array below
Pic[20] = 'photos/sperber/dock2SM.jpg'
Pic[21] = 'photos/sperber/dock3SM.jpg'
Pic[22] = 'photos/sperber/dock6SM.jpg'
Pic[23] = 'photos/sperber/exterior2SM.jpg'
Pic[24] = 'photos/sperber/baywindowsSM.jpg'
// do not edit anything below this line
var t;
var j = 20;
var p = Pic.length;
var preLoad = new Array2();
for (i = 20; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow2() {
if (document.all) {
document.images.SlideShow2.style.filter="blendTrans(duration=2)";
document.images.SlideShow2.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow2.filters.blendTrans.Apply();
}
document.images.SlideShow2.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow2.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 20;
t = setTimeout('runSlideShow2()', slideShowSpeed);
}
// End -->
</script>