Pb menu dynamique JS

Pb menu dynamique JS - HTML/CSS - Programmation

Marsh Posté le 29-08-2003 à 11:41:48    

J'ai un pb avec un menu dynamique en JS. En gros, j'ai des menu et qd on clique sur le menu on affiche les sous-menu etc...
Le truc c'est que qd je clique sur le menu, ce con se decale sur la gauche alors que je lui ai rien demandé ^^
Depuis hier je me prends la tete à comprendre pourkoi le menu se decale tout seul et franchement j'ai cherché.
 
Voilà le script en question:
 

Code :
  1. <script language="javascript">
  2. var intCount = 0;
  3. function DynamicMenu_addParent(strName) {
  4. var strID = 'ID' + intCount++;
  5. var strTemp = '<DIV ID="' + strID + '" CLASS="parent"';
  6.         strTemp += ' onClick="expandCollapse(this);">';
  7.         strTemp += '<img src="./Images/ats_ci_arrow_wh.gif" />' + strName ;
  8.         strTemp += '<DIV STYLE="display: none" CLASS="child"></DIV>';
  9.         strTemp += '</DIV>';
  10. this.div.innerHTML += strTemp;
  11.         this.currentChild = document.getElementById(strID);
  12. }
  13. function DynamicMenu_addChild(strName,strURL) {
  14. var strTemp = '<img src="./Images/ats_ci_arrow_simple_wh.gif" /><a href="' + strURL + '"' + ' >' + strName + '</a><br />';
  15. if (document.all) {
  16.          this.currentChild.children[1].innerHTML += strTemp;
  17. } else {
  18.          this.currentChild.childNodes[2].innerHTML += strTemp;
  19. }
  20. }
  21. function cancelBubble(netEvent) {
  22. if (document.all) {
  23.  window.event.cancelBubble = true;
  24. } else {
  25.          netEvent.cancelBubble = true;
  26. }
  27. }
  28. function expandCollapse(objElement) {
  29. if (document.all) {
  30.          var imgIcon = objElement.children[0];
  31.                 objElement = objElement.children[1];
  32. } else {
  33.          var imgIcon = objElement.childNodes[0];
  34.                 objElement = objElement.childNodes[2];
  35. }
  36. if (objElement.style.display == "none" ) {
  37.          objElement.style.display = "block" ;
  38.                 imgIcon.src = "./Images/ats_ci_arrow_wh.gif" ;
  39. } else {
  40.          objElement.style.display = "none" ;
  41.                 imgIcon.src = "./Images/ats_ci_arrow_wh.gif" ;
  42. }
  43. }
  44. function DynamicMenu() {
  45. var id = "Menu" + intCount++;
  46.         document.write('<DIV Id="' + id + '"></DIV>');
  47. this.div = document.getElementById(id);
  48.         this.currentChild = null;
  49. this.addParent = DynamicMenu_addParent;
  50.         this.addChild = DynamicMenu_addChild;
  51. }
  52. </script>
  53. </head>
  54. ...


 
et l'utilisation :
 

Code :
  1. <td><img src="./Images/ats_blind.gif" height=1px width=12 border=0 /></td>
  2.       <td><br />
  3.      <script language="Javascript">
  4.      var menu = new DynamicMenu();
  5.      menu.addParent('Site Accenture Technology Solutions');
  6.      menu.addChild('Pr&eacute;sentation des bureaux', 'test.html');
  7.      menu.addParent('Droits et Devoirs');
  8.      menu.addChild('T&eacute;l&eacute;phone', 'environnement02.html');
  9.      menu.addChild('Fax', 'environnement03.html');
  10.      </script><br /><br />
  11.      </td>
  12.     <td><img src="./Images/ats_blind.gif" height=1px width=10px border=0></td>


 
En plus je vous mets un ti exemple pour vous montrez ce qu'il fait le saligau !!
 
 
http://www.bootsquad.net/test.html
 
 
Helppp plizzz


Message édité par dirakocha le 29-08-2003 à 11:42:49

---------------
Q.G Tutoriaux ici
Reply

Marsh Posté le 29-08-2003 à 11:41:48   

Reply

Marsh Posté le 30-08-2003 à 16:04:33    

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed