Ho scritto questa breve funzione per gestire un onmouseover
vorrei che al mouseout l'immagine iniziale venga ripristinata dopo qualche secondo, ho provato inserendo un setTimeout con un richiamo ad una funzione esterna ma non funziona. Sapete dirmi perchè?
Codice PHP:
function domRollover() {
var imgarr=document.getElementsByTagName('a');
var imgPreload=new Array();
for (i=0;i<imgarr.length;i++){
if(imgarr[i].className=='quad_link'){
imgPreload[i]=new Image();
imgPreload[i].src = 'img/icons/'+imgarr[i].id;
imgarr[i].onmouseover = function(){
document.getElementById(this.name).src='img/icons/'+this.id;
//alert(this.id);
}
imgarr[i].onmouseout = function(){
setTimeout('rollOut()',2000,this.name);
}
} // chiude if
} // chiude for
} //chiude function
domRollover();
function rollOut(img_name) {
document.getElementById(img_name).src='img/icons/label_'+img_name+'.gif';
}