Code javascript sous IE

Fermé
magickirua - 23 nov. 2007 à 18:43
 magickirua - 23 nov. 2007 à 19:29
Bonjour,
J'ai un code en javascript qui fonctionne sur Firefox mais pas sur IE.
C'est simplement un code qui change d'image en fonction d'une valeur. Et donc, comment faire pour que ça fonctionne sur les deux?
Merci d'avance!

<html>
<head>
<title>Sabliers</title>

<style type="text/css">
table{ margin-left:auto;margin-right:auto;width:300px;}
td { text-align:center; font-family:Georgia; font-size:xx-large; }
td.gryffondor{ color:#FF3300; height:50px; }
td.serdaigle{ color:#3366CC; height:50px; }
td.poufsouffle{ color:#CCFF33; height:50px; }
td.serpentard{ color:#33CC33; height:50px; }
</style>

<script language="JavaScript" type="text/javascript">

function sabliers()
{
var table,tr,td,body,i,j;
body=document.getElementsByTagName("BODY")[0];
table=document.createElement("TABLE");
table.cellSpacing=0;
table.cellPadding=0;

for(i=0;i<2;i++)
{
tr=document.createElement("TR");



for(j=0;j<4;j++)
{
if (i==1)
{
td=document.createElement("TD");
p=document.createElement("P");
img=document.createElement("img");
if(j==0)
{gryf=document.getElementById(1);

if (gryf.value<=300){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (gryf.value>300 && gryf.value<=600){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (gryf.value>600 && gryf.value<=900){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (gryf.value>900 && gryf.value<=1200){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (gryf.value>1200 && gryf.value<=1500){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (gryf.value>1500 && gryf.value<=1800){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (gryf.value>1800){ img.src="http://tinypic.com/images/goodbye.jpg"; }
}
if(j==1)
{
serd=document.getElementById(2);

if (serd.value<=300){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serd.value>300 && serd.value<=600){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serd.value>600 && serd.value<=900){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serd.value>900 && serd.value<=1200){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serd.value>1200 && serd.value<=1500){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serd.value>1500 && serd.value<=1800){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serd.value>1800){ img.src="http://tinypic.com/images/goodbye.jpg"; }
}
if(j==2)
{
pouf=document.getElementById(3);
if (pouf.value<=300){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (pouf.value>300 && pouf.value<=600){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (pouf.value>600 && pouf.value<=900){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (pouf.value>900 && pouf.value<=1200){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (pouf.value>1200 && pouf.value<=1500){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (pouf.value>1500 && pouf.value<=1800){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (pouf.value>1800){ img.src="http://tinypic.com/images/goodbye.jpg"; }
}
if(j==3)
{
serp=document.getElementById(4);
if (serp.value<=300){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serp.value>300 && serp.value<=600){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serp.value>600 && serp.value<=900){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serp.value>900 && serp.value<=1200){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serp.value>1200 && serp.value<=1500){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serp.value>1500 && serp.value<=1800){ img.src="http://tinypic.com/images/goodbye.jpg"; }
if (serp.value>1800){ img.src="http://tinypic.com/images/goodbye.jpg"; }
}
td.appendChild(img);
tr.appendChild(td);

}
if(i==0)
{
td=document.createElement("TD");
p=document.createElement("P");
if(j==0){ td.className="gryffondor"; td.id=1; points=100; }
if(j==1){ td.className="serdaigle"; td.id=2; points=100; }
if(j==2){ td.className="poufsouffle"; td.id=3; points=100; }
if(j==3){ td.className="serpentard"; td.id=4; points=150; }

p.innerHTML=points;
td.value=points;
td.appendChild(p);
tr.appendChild(td);
}
}

table.appendChild(tr);
body.appendChild(table);
}

}

</script>
</head>
<body onload="sabliers();">

</body>
</html>
A voir également:

2 réponses

sfel Messages postés 1640 Date d'inscription lundi 18 juin 2007 Statut Membre Dernière intervention 15 juillet 2009 430
23 nov. 2007 à 19:10
bonjour, avant tout, de quel version d'IE parles-tu ??? 5, 6 ou 7 ? ou les trois

et surtout sur la(les)quel(s) veux-tu faire fonctionner ton script ?? (ne considère pas IE 5, il es tun peu trop obsolète)
0
eh bien, version 6 et 7 si possible. (Sachant que je déteste IE :P mais je le fais pour les usagers de mon site...)
0