So che il titolo è un po improvvisato, ma non sapevo cosa metterci, in quanto anche il problema è molto strano. In poche parole, ho un blocco di codice
codice:
function setAlbum(name){
document.getElementById("photos").innerHTML = "";
var a = 0;
var album = albums[a];
while (name != albums[a].getAttribute("name")) {
a++;
album = albums[a];
}
var photos = album.getElementsByTagName("photo");
document.getElementById("photos").innerHTML = "";
for (var a = 0; a < photos.length; a++) {
var photo = document.createElement("img");
photo.src = photos[a].childNodes[0].nodeValue;
photo.alt = "photo";
photo.style.opacity = "0.1";
document.getElementById("photos").appendChild(photo);
elem = photo;
setInterval("fade()", 50);
}
}
var i = 0;
var elem = null;
function fade(){
if (i < 1) {
i += 0.1;
alert(i);
elem.style.opacity = i;
setTimeout("fade()", 50);
alert("a");
}
else {
elem.style.opacity = "1";
i = 0;
}
}
Che quando viene eseguito, funziona come impostato, ma il "for" che chiama 3 volte la funzione "fade", la chiama senza aspettare che questa abbia finito di eseguirsi...
Pensate che si possa fare in qualche modo?
Grazie,