Can anybody tell me why the javascript for the gallery on the page below is fine in Firefox, but isn't working properly in Chrome and Safari?
http://luxe-deluxe.com/collections/winter2011.html
In Chrome, the big image doesn't show up but the thumbnails do, and in Safari nothing shows up.
'Don't think it could have anything to do with the css..开发者_JAVA技巧. could it?
any help is appreciated... I'll post the answer if I find it. arg!
The line:
document.images.src = img[imgNumber];
isn't working. It should be
document.getElementById('images').src = img[imgNumber];
Same with the line
document.images.src = img[this.id];
It should be:
document.getElementById('images').src = img[this.id];
Once those were fixed, the slideshow worked for me in a local copy.
I am getting <img src="" id="images">
with no source.
Try to alert alert(document.images.src);
== undefined.
Try document.getElementById("images").src
instead.
var NumberOfImages = 9
var img = new Array(NumberOfImages)
img[0] = "Susielookbook-561.jpg"
img[1] = "Luxe Deluxe W11 (9).jpg"
img[2] = "Luxe Deluxe W11 (10).jpg"
img[3] = "Luxe Deluxe W11 (13).jpg"
img[4] = "Luxe Deluxe W11 (19).jpg"
img[5] = "Susielookbook-259.jpg"
img[6] = "Susielookbook-293.jpg"
img[7] = "Susielookbook-431.jpg"
img[8] = "Susielookbook-613.jpg"
var imgNumber = 0;
function setupImages(){
document.images.src = img[imgNumber];
for(var x=0; x < img.length; x++){
var thumb = document.createElement('img');
thumb.setAttribute('src', 't_'+img[x]);
thumb.id = x;
thumb.onclick = function(){
document.images.src = img[this.id];
imgNumber = this.id;
alert(document.images.src); // <-- here
}
document.getElementById('thumbnailholder').appendChild(thumb);
}
}
function NextImage() {
imgNumber++;
if (imgNumber == NumberOfImages){
imgNumber = 0;
}
document.images.src = img[imgNumber];
}
function PreviousImage() {
imgNumber--;
if (imgNumber < 0){
imgNumber = NumberOfImages - 1;
}
document.images.src = img[imgNumber];
}
精彩评论