NekoChan: Drop-Down Menu: Horizontal Style

Hallo, ich habe ein Problem mit der Navigation auf meiner Webseite.

So sieht die Navigation aus: http://freenet-homepage.de/animessing/problem.html

(auf die Pfeile klicken, dann öffnet sich rechts eine Leiste)

Problem: Es öffnet sich immer die gleiche Leiste, egal auf welchen Pfeil man klickt. Es öffnet sich immer das erste Menu. Im HTML-Code, den ich unten in diesen Beitrag bei SelfHTML eingefügt habe, kann man es genauer sehen. Warum ist das so? Liegt es an den JavaScript? Bitte helft mir!

----C-O-D-E----------------------------------------------------------

<div style="width:130px; height:400px; float: left;" id="Info">

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin var refer=true; function combo() { if (refer) {   document.all.contents3.style.visibility="visible";   refer=false; } else {   document.all.contents3.style.visibility="hidden";   refer=true; } } //  End --> </script>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin var refer=true; function combo() { if (refer) {   document.all.contents2.style.visibility="visible";   refer=false; } else {   document.all.contents2.style.visibility="hidden";   refer=true; } } //  End --> </script>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin var refer=true; function combo() { if (refer) {   document.all.contents.style.visibility="visible";   refer=false; } else {   document.all.contents.style.visibility="hidden";   refer=true; } } //  End --> </script>

</head> <body>

<table cellspacing="0" cellpadding="0" align="left"> <tr> <td>

<table style="border:0px solid #000000;" width="168" border="0" cellspacing="0" cellpadding="0" bordercolor="#333333">   <tr>     <td align="left" bgcolor="#c9c9c9">       <font face="arial" color="#666666"><span style="font-size:14px;">&#160;<b>T E S T O B J E K T</b></font></span>     </td>     <td title="Klick hier um das Menü zu öffnen" style="border-left:0px solid #c9c9c9;background:#c9c9c9;" align="right" width="26" onclick="combo()">      <img src="Pfeil.gif"> </td>   </tr></td></tr> </table>

<div id="contents" style="position:absolute; left:180px; top:13px; width:156px; height:?px; z-index:9; visibility:hidden">

<table style="border:0px solid #000000;" width="125" border="0" cellspacing="2" cellpadding="0" bordercolor="#e6e6e6">   <tr>     <td bgcolor="#e6e6e6">       <font color="#FFFFFF" face="arial" size="1">

<tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" class="menulink2" target="home" class=&{ns4class};><font color=#333333> &#215; Testobjekt</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333>&#215; Testobjekt</font></a></td></tr>

</div>

</font>     </td>   </tr> </table> </td> </tr> </table>

<br><br>

<table cellspacing="0" cellpadding="0" align="left"> <tr> <td>

<table style="border:0px solid #000000;" width="168" border="0" cellspacing="0" cellpadding="0" bordercolor="#333333">   <tr>     <td align="left" bgcolor="#c9c9c9">       <font face="arial" color="#666666"><span style="font-size:14px;">&#160;<b>T E S T O B J E K T</b></font></span>     </td>     <td title="Klick hier um das Menü zu öffnen" style="border-left:0px solid #c9c9c9;background:#c9c9c9;" align="right" width="26" onclick="combo()">      <img src="Pfeil.gif"> </td>   </tr> </table>

<div id="contents2" style="position:absolute; left:170px; top:240px; width:156px; height:?px; z-index:8; visibility:hidden">

<table style="border:0px solid #000000;" width="125" border="0" cellspacing="2" cellpadding="0" bordercolor="#e6e6e6">   <tr>     <td bgcolor="#e6e6e6">       <font color="#FFFFFF" face="arial" size="1">

<tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" class="menulink2" target="home" class=&{ns4class};><font color=#333333> &#215; Testobjekt2</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt2</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt2</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt2</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333>&#215; Testobjekt2</font></a></td></tr>       </div>

</font>     </td>   </tr> </table> </td> </tr> </table>

<br><br>

<table cellspacing="0" cellpadding="0" align="left"> <tr> <td>

<table style="border:0px solid #000000;" width="168" border="0" cellspacing="0" cellpadding="0" bordercolor="#333333">   <tr>     <td align="left" bgcolor="#c9c9c9">       <font face="arial" color="#666666"><span style="font-size:14px;">&#160;<b>T E S T O B J E K T</b></font></span>     </td>     <td title="Klick hier um das Menü zu öffnen" style="border-left:0px solid #c9c9c9;background:#c9c9c9;" align="right" width="26" onclick="combo()">      <img src="Pfeil.gif"> </td>   </tr> </table>

<div id="contents2" style="position:absolute; left:170px; top:240px; width:156px; height:?px; z-index:7; visibility:hidden">

<table style="border:0px solid #000000;" width="125" border="0" cellspacing="2" cellpadding="0" bordercolor="#e6e6e6">   <tr>     <td bgcolor="#e6e6e6">       <font color="#FFFFFF" face="arial" size="1">

<tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" class="menulink2" target="home" class=&{ns4class};><font color=#333333> &#215; Testobjekt3</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt3</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt3</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt3</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333>&#215; Testobjekt3</font></a></td></tr>      </div>

</font>     </td>   </tr> </table> </td> </tr> </table>

<br><br>

<table cellspacing="0" cellpadding="0" align="left"> <tr> <td>

<table style="border:0px solid #000000;" width="168" border="0" cellspacing="0" cellpadding="0" bordercolor="#333333">   <tr>     <td align="left" bgcolor="#c9c9c9">       <font face="arial" color="#666666"><span style="font-size:14px;">&#160;<b>T E S T O B J E K T</b></span></font>     </td>     <td title="Klick hier um das Menü zu öffnen" style="border-left:0px solid #c9c9c9;background:#c9c9c9;" align="right" width="26" onclick="combo()">      <img src="Pfeil.gif"> </td>   </tr> </table>

<div id="contents2" style="position:absolute; left:170px; top:240px; width:156px; height:?px; z-index:6; visibility:hidden">

<table style="border:0px solid #000000;" width="125" border="0" cellspacing="2" cellpadding="0" bordercolor="#e6e6e6">   <tr>     <td bgcolor="#e6e6e6">       <font color="#FFFFFF" face="arial" size="1">

<tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" class="menulink2" target="home" class=&{ns4class};><font color=#333333> &#215; Testobjekt4</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt4</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt4</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt4</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333>&#215; Testobjekt4</font></a></td></tr>       </div>

</font>     </td>   </tr> </table> </td> </tr> </table>

<br><br>

<table cellspacing="0" cellpadding="0" align="left"> <tr> <td>

<table style="border:0px solid #000000;" width="168" border="0" cellspacing="0" cellpadding="0" bordercolor="#333333">   <tr>     <td align="left" bgcolor="#c9c9c9">       <font face="arial" color="#666666"><span style="font-size:14px;">&#160;<b>T E S T O B J E K T</b></font></span>     </td>     <td title="Klick hier um das Menü zu öffnen" style="border-left:0px solid #c9c9c9;background:#c9c9c9;" align="right" width="26" onclick="combo()">      <img src="Pfeil.gif"> </td>   </tr> </table>

<div id="contents2" style="position:absolute; left:170px; top:240px; width:156px; height:?px; z-index:5; visibility:hidden">

<table style="border:0px solid #000000;" width="125" border="0" cellspacing="2" cellpadding="0" bordercolor="#e6e6e6">   <tr>     <td bgcolor="#e6e6e6">       <font color="#FFFFFF" face="arial" size="1">

<tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" class="menulink2" target="home" class=&{ns4class};><font color=#333333> &#215; Testobjekt5</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt5</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt5</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333> &#215; Testobjekt5</font></a></td></tr>    <tr bgcolor="#c9c9c9"><td align=left><a href="testobjekt.html" target="home" class="menulink2" class=&{ns4class};><font color=#333333>&#215; Testobjekt5</font></a></td></tr>       </div>

</font>     </td>   </tr> </table> </td> </tr> </table>

</div>

  1. Bei dem Codegewurschtel ist es erstaunlich, dass überhaupt was geht ;-)

    Du hast mehrfach die Gleiche Funktion - combo(), der Browser interpretiert von oben nach unten und bleibt dann dementprechend bei der letzten Deklaration von combo() hängen, wenn er die Funktion aufrufen will ... ja und dort wird halt immer der DIV contents beeinflusst.

    Zum einen solltest du den Code in Ordnung bringen, dann darfst du den gleichen Funktionsnamen nicht merhfach verwenden ... übergebe doch einen Parameter um welche combo es sich handelt.
    Ja und dann lasse bitte document.all ... weg ... dafür gibts
    < http://de.selfhtml.org/javascript/objekte/document.htm#get_element_by_id>

    mfg
    Knuspeklumpen

    1. Sorry, aber das hab ich nicht so ganz geblickt...
      Könntest du (oder ein anderer) mir es genauer erklären oder den HTML-Code vielleicht so ändern, dass es funktioniert?