ciao io ho un problema
ho una funzione che mi setta gli attributi di un immagine e ad ogni immagine vorrei passargli all'onclick una funzione...
attualmente faccio cosi, con firefox funziona, mentre con explorer no!
function changeGalleryImage(index) {
// creo il div di scambio con l'immagine
createDiv();
var imageViewer = document.getElementById("imageViewer");
var imageTitle = document.getElementById("imageTitle");
var imageDescription = document.getElementById("imageDescription");
var thumbnailsLayer = document.getElementById("thumbnailsLayer");
var thumbIndex = 1;
selectedImageIndex = index;
//creo l'immagine grande piu titolo e descrizione
imageViewer.src = galleries[selectedGalleryIndex][selectedImageIndex] + ".jpg";
imageTitle.innerHTML = titles[selectedGalleryIndex][selectedImageIndex];
imageDescription.innerHTML = descriptions[selectedGalleryIndex][selectedImageIndex];
for (imageIndex = 0; imageIndex < galleries[selectedGalleryIndex].length; imageIndex++) {
if (imageIndex == selectedImageIndex)
continue;
var imageElement = document.getElementById("imageThumb" + thumbIndex);
thumbIndex++;
imageElement.setAttribute("type", "image");
imageElement.setAttribute("src", galleries[selectedGalleryIndex][imageIndex] + "_thumb.jpg");
imageElement.setAttribute("alt", titles[selectedGalleryIndex][imageIndex]);
imageElement.setAttribute("title", descriptions[selectedGalleryIndex][imageIndex]);
imageElement.setAttribute("onclick", "changeGalleryImage(" + imageIndex + ")");
}
}
avevo provato sostituire la riga:
imageElement.setAttribute("onclick", "changeGalleryImage(" + imageIndex + ")");
con:
imageElement.onclick = changeGalleryImage( imageIndex);
ma mi va in loop infinito...
qualcuno vede dove faccio l'errore ?