webForumDet fria alternativet

Ännu en menyfråga

4 svar · 264 visningar · startad av Obbelix

ObbelixMedlem sedan okt. 2002257 inlägg
#1

Hej.

Använder nedanstående kod till en meny. Den fungerar som den ska i IE, Safari mfl men inte i mozilla/FireFox.
Vet nån hur man kan ändra den så att den fungerar i alla läsare?

<html>
 <head>
 <SCRIPT LANGUAGE="JavaScript"><!--
 function VisaMeny(Meny,Bild) {
   if (Meny.style.display == "none") {
     Meny.style.display = "";
     Bild.src = "arrowdown.gif";
   }
   else {
     Meny.style.display = "none";
     Bild.src = "arrowout.gif";
   }
 }
//-->
 </SCRIPT>
 </head>
 <body>
  <table border="0" cellpadding="0" cellspacing="1">
   <tr valign=top>
    <td width="11" height="18">
     <div onClick="VisaMeny(m1,p1)">
      <img src="arrowout.gif" border="0" width="8" height="8" id="p1">
     </div>
    </td>
    <td width="100" height="18">
     <div onClick="VisaMeny(m1,p1)">
      <a href="#" onFocus="this.blur()">Fäll ut 1</a>
     </div>
     <span id="m1" STYLE="display: none">
      &nbsp;<a target="main" href="#">Sida 1</a><br>
      &nbsp;<a target="main" href="#">Sida 2</a><br>
      &nbsp;<a target="main" href="#">Sida 3</a><br>
      &nbsp;<a target="main" href="#">Sida 4</a><br>
     </span>
    </td>
   </tr>
  </table>
 </body>
</html>
Nexus86Medlem sedan okt. 20023 030 inlägg
#2
<html>
 <head>
 <SCRIPT LANGUAGE="JavaScript"><!--
 function VisaMeny(Meny,Bild) {
   if (document.getElementById(Meny).style.display == "none") {
     document.getElementById(Meny).style.display = "";
     document.getElementById(Bild).src = "arrowdown.gif";
   }
   else {
     document.getElementById(Meny).style.display = "none";
     document.getElementById(Bild).src = "arrowout.gif";
   }
 }
//-->
 </SCRIPT>
 </head>
 <body>
  <table border="0" cellpadding="0" cellspacing="1">
   <tr valign=top>
    <td width="11" height="18">
     <div onClick="VisaMeny(m1,p1)">
      <img src="arrowout.gif" border="0" width="8" height="8" id="p1">
     </div>
    </td>
    <td width="100" height="18">
     <div onClick="VisaMeny(m1,p1)">
      <a href="#" onFocus="this.blur()">Fäll ut 1</a>
     </div>
     <span id="m1" STYLE="display: none">
       <a target="main" href="#">Sida 1</a><br>
       <a target="main" href="#">Sida 2</a><br>
       <a target="main" href="#">Sida 3</a><br>
       <a target="main" href="#">Sida 4</a><br>
     </span>
    </td>
   </tr>
  </table>
 </body>
</html>
ObbelixMedlem sedan okt. 2002257 inlägg
#3

Funkar inte... Får fel på raden

if (document.getElementById(Meny).style.display == "none") {

Felmeddelande: "Objekt krävs"

nitro2k01Medlem sedan aug. 20039 342 inlägg
#4
<div onClick="VisaMeny('m1','p1')">
ObbelixMedlem sedan okt. 2002257 inlägg
#5

Japp, nu funkar det.

Stort tack!

134 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
131 ms — hämta tråd, inlägg och bilagor (db)