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://i16.tinypic.com/6odltm0.jpg"; }
if (gryf.value>300 && gryf.value<=600){ img.src="
http://i12.tinypic.com/6y0s6pv.jpg"; }
if (gryf.value>600 && gryf.value<=900){ img.src="
http://i14.tinypic.com/7wsdhyx.jpg"; }
if (gryf.value>900 && gryf.value<=1200){ img.src="
http://i9.tinypic.com/7y2n8u8.jpg"; }
if (gryf.value>1200 && gryf.value<=1500){ img.src="
http://i18.tinypic.com/6wo2yb9.jpg"; }
if (gryf.value>1500 && gryf.value<=1800){ img.src="
http://i16.tinypic.com/6wrpvm0.jpg"; }
if (gryf.value>1800){ img.src="
http://i9.tinypic.com/8fw8rjk.jpg"; }
}
if(j==1)
{
serd=document.getElementById(2);
if (serd.value<=300){ img.src="
http://i10.tinypic.com/6pefwqp.jpg"; }
if (serd.value>300 && serd.value<=600){ img.src="
http://i16.tinypic.com/6l17shy.jpg"; }
if (serd.value>600 && serd.value<=900){ img.src="
http://i11.tinypic.com/6lcuh5f.jpg"; }
if (serd.value>900 && serd.value<=1200){ img.src="
http://i9.tinypic.com/6z5re3m.jpg"; }
if (serd.value>1200 && serd.value<=1500){ img.src="
http://i13.tinypic.com/80wu1vr.jpg"; }
if (serd.value>1500 && serd.value<=1800){ img.src="
http://i13.tinypic.com/6yl8g9v.jpg"; }
if (serd.value>1800){ img.src="
http://i19.tinypic.com/869ubvb.jpg"; }
}
if(j==2)
{
pouf=document.getElementById(3);
if (pouf.value<=300){ img.src="
http://i14.tinypic.com/8esbcio.jpg"; }
if (pouf.value>300 && pouf.value<=600){ img.src="
http://i3.tinypic.com/86heb7o.jpg"; }
if (pouf.value>600 && pouf.value<=900){ img.src="
http://i15.tinypic.com/836vdir.jpg"; }
if (pouf.value>900 && pouf.value<=1200){ img.src="
http://i12.tinypic.com/6xbuyhy.jpg"; }
if (pouf.value>1200 && pouf.value<=1500){ img.src="
http://i13.tinypic.com/8211j51.jpg"; }
if (pouf.value>1500 && pouf.value<=1800){ img.src="
http://i8.tinypic.com/7w7lcec.jpg"; }
if (pouf.value>1800){ img.src="
http://i15.tinypic.com/870ppj7.jpg"; }
}
if(j==3)
{
serp=document.getElementById(4);
if (serp.value<=300){ img.src="
http://i6.tinypic.com/6ltu7np.jpg"; }
if (serp.value>300 && serp.value<=600){ img.src="
http://i5.tinypic.com/72741mf.jpg"; }
if (serp.value>600 && serp.value<=900){ img.src="
http://i4.tinypic.com/6yd1qhs.jpg"; }
if (serp.value>900 && serp.value<=1200){ img.src="
http://i3.tinypic.com/8719fth.jpg"; }
if (serp.value>1200 && serp.value<=1500){ img.src="
http://i6.tinypic.com/85ay9hl.jpg"; }
if (serp.value>1500 && serp.value<=1800){ img.src="
http://i12.tinypic.com/6s9iotu.jpg"; }
if (serp.value>1800){ img.src="
http://i1.tinypic.com/86jy3cw.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>
Configuration: Windows XP
Firefox 2.0.0.9