[IE] Boucle for, truc de fou
Bonjour à tous,
Ca fait une heure que j'essaye de débugger ce satané code IE.
Tout fonctionne sous FF comme d'hab.
Sous IE 7, c'est surprenant !
Voici mon code optimisé IE :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| var tab=new Array();
var tab_img=new Array('ac', 'pk', 'bp', 'ht');
function zoom(container, maxWidth, maxHeight, minWidth, minHeight){
for(var i=0; i<tab_img.length; i++){
tab[i]=false;
var newimg=document.createElement('img');
newimg.setAttribute('src', 'img/'+tab_img[i]+'.gif');
newimg.setAttribute('id', 'img'+i);
newimg.style.setAttribute('cssText', 'width:'+minWidth+'px; height:'+minHeight+'px;');
newimg.setAttribute("onclick", function(){alert('Play '+i);});
document.getElementById(container).appendChild(newimg);
}
}
window.onload=function(){
zoom('area', 68, 107, 34, 54);
} |
Dans mon HTML, j'ai juste
Code:
<div id="area"></div>
Donc toutes mes images ont un onclick="alert('Play 4');" !!?
C'est fou.. je me suis lu et relu. Je vois pas où j'ai merdé.