Bonjour,
j'ai un problème avec la fonction getElementByName sous Internet Explorer. Je tiens à préciser que sous Firefox ça marche très bien.
Alors voilà, j'ai fait un système d'onglets et quand je clique sur un onglet, je le fais apparaître autrement. Alors, pour cela j'utilise les feuilles de style en mettant l'onglet courant dans une balise DIV avec ID="current". Chaque fois que je clique sur un onglet, je lance une fonction JavaScript pour changer les attributs des balises DIV, notamment ID.
Voyez mon code, vous comprendrez mieux j'espère...
<HTML>
<HEAD>
<TITLE>Test Onglets + JavaScript</TITLE>
<!-- Fonctions JavaScript //-->
<SCRIPT LANGUAGE="JavaScript">
<!--
// Fonction qui change l'onglet courant
function changeOnglet(number_onglet) {
var liste_onglets = document.getElementsByName("onglet") ;
var texte_onglets = document.getElementsByName("texte") ;
// ===> Ces deux fonctions merdent sous IE. Quand je demande
// la valeur de liste_onglets.length et texte_onglets.length, ça me
// renvoie pour les deux 0 :-(
for(i=0; i<liste_onglets.length; i++) {
liste_onglets[i].id="";
texte_onglets[i].style.display="none" ;
}
liste_onglets[number_onglet].id="current";
texte_onglets[number_onglet].style.display="" ;
}
//-->
</SCRIPT>
<!-- Feuilles de style CSS //-->
<STYLE TYPE="text/css">
// Tout plein de feuilles de style CSS dont
#header #current {
background-image:url("left_on.gif");
}
#header #current SPAN {
background-image:url("right_on.gif");
color:#333;
padding-bottom:5px;
cursor:default;
}
</STYLE>
</HEAD>
<BODY>
<!-- Génération dynamique des onglets //-->
<DIV NAME="header" ID="header">
<UL>
<LI NAME="onglet" ONCLICK="changeOnglet(0)" ID="current">
<SPAN STYLE="">1<SUP>er</SUP> onglet</SPAN>
</LI>
<LI NAME="onglet" ONCLICK="changeOnglet(1)" ID="">
<SPAN STYLE="cursor:hand">2<SUP>ème</SUP> onglet</SPAN>
</LI>
<LI NAME="onglet" ONCLICK="changeOnglet(2)" ID="">
<SPAN STYLE="cursor:hand">3<SUP>ème</SUP> onglet</SPAN>
</LI>
<LI NAME="onglet" ONCLICK="changeOnglet(3)" ID="">
<SPAN STYLE="cursor:hand">4<SUP>ème</SUP> onglet</SPAN>
</LI>
<LI NAME="onglet" ONCLICK="changeOnglet(4)" ID="">
<SPAN STYLE="cursor:hand">5<SUP>ème</SUP> onglet</SPAN>
</LI>
<LI NAME="onglet" ONCLICK="changeOnglet(5)" ID="">
<SPAN STYLE="cursor:hand">6<SUP>ème</SUP> onglet</SPAN>
</LI>
</UL>
</DIV>
<DIV NAME="texte" STYLE="display:block">one</DIV>
<DIV NAME="texte" STYLE="display:none">two</DIV>
<DIV NAME="texte" STYLE="display:none">three</DIV>
<DIV NAME="texte" STYLE="display:none">four</DIV>
<DIV NAME="texte" STYLE="display:none">five</DIV>
<DIV NAME="texte" STYLE="display:none">six</DIV>
</BODY>
</HTML>
et donc ça ne marche pas...
J'espère que vous réussirez à m'aider
Cordialement,
Flavien