I have 3 Galleries on a website controlled by on each of the seperate pages by <body onLoad="photoGallery()"> with the function detail for each of the galleries in the <head> section of the individual pages.... and everything worked fine!
When I seek to collect all my Javascripts bits into a .js file the Galleries no longer work! The .js file connects with the pages fine as all the other javascripts work.
I am using
var c=0
var s
function photoGallery()
{
if (c%3==0){document.getElementById('photo-gallery').src = "sequence1.jpg";}
if (c%3==1){document.getElementById('photo-gallery').src = "sequence2.jpg";}
if (c%3==2){document.getElementById('photo-gallery').src = "sequence3.jpg";}
c=c+1
s=setTimeout("photoGallery()",1600)
}
I have tried different things to give the Galleries a different identity but cannot get to work! Is there a way around this or do I have to keep the function script in the head sections?
var c=0
var s
function photoGallery()
{
if (c%3==0){document.getElementById('photo-gallery').src = "sequence1.jpg";}
if (c%3==1){document.getElementById('photo-gallery').src = "sequence2.jpg";}
if (c%3==2){document.getElementById('photo-gallery').src = "sequence3.jpg";}
c=c+1
s=setTimeout("photoGallery()",1600)
}
to...
Code:
var c=0
var s
function photoGallery() {
var tcnt = (c % 3) + 1;
document.getElementById('photo-gallery').src = "sequence"+tcnt+".jpg";
c=c+1;
s=setTimeout("photoGallery()",1600);
}
Untested, but it should be close to what you want.
The reduced and tightened code certainly reduces the overly-repetitve code in a photoGallery with a large number of images. However, I have not as yet got the reduced code to work!
The reduced and tightened code certainly reduces the overly-repetitve code in a photoGallery with a large number of images. However, I have not as yet got the reduced code to work!
I'm not exactly sure how we can help without seeing your whole code associated with the gallery
with your post explanations published above.
The working code in the long form which is working by displaying the sequence
var c=0
var s
function photoGallery()
{
if (c%7==0){document.getElementById('photo-Gallery').src = "sequence1.jpg";}
if (c%7==1){document.getElementById('photo-Gallery').src = "sequence2.jpg";}
if (c%7==2){document.getElementById('photo-Gallery').src = "sequence3.jpg";}
if (c%7==3){document.getElementById('photo-Gallery').src = "sequence4.jpg";}
if (c%7==4){document.getElementById('photo-Gallery').src = "sequence5.jpg";}
if (c%7==5){document.getElementById('photo-Gallery').src = "sequence6.jpg";}
if (c%7==6){document.getElementById('photo-Gallery').src = "sequence7.jpg";}
c=c+1
s=setTimeout("photoGallery()",1600)
}
Trying to get this reduced (your) code working but currently without success. Thanks for your patients.
var c=0
var s
function photoGallery() {
var tcnt = (c % 7) + 1;
document.getElementById('photo-gallery').src = "sequence"+tcnt+".jpg";
c=c+1;
s=setTimeout(photoGallery, 1600);
}
I have a lot of images feeding three of these javascript image galleries. I tried tidying up by putting all the images in a folder named box. l then placed the folder name box as follows .src = "box/sequence"+tcnt+".jpg"; but it did not work!
var c=0
var s
function imageGallery() {
var tcnt = (c % 7) + 1;
document.getElementById('photo-gallery').src = "sequence"+tcnt+".jpg";
c=c+1;
s=setTimeout(imageGallery, 1600);
}
Bookmarks