ritschmanhard: dropdown menü

Beitrag lesen

Hi Toni!

Ich glaube zwar nicht, das du willst, was du beschreibst, aber ich gebe dir hier mal ein Beispiel (2 Dateien, zum Ausprobieren test2 zuerst starten); das ganze funktioniert nur korrekt, wenn du keine Anker verwendest:
<html>
<head>
 <title>ich bin test2.htm</title>
 <script type="text/javascript">

function setAuswahl (index)
 {
  self.location.replace("./test1.htm#"+index);
 }

function testOldSel()
 {
  var mySel=window.location.hash;
  if (mySel!="")
  {
   mySel = mySel.replace(/#/,"");
   document.Testform.Auswahl.options[mySel].selected = true;
  }
  else
   document.Testform.Auswahl.options[0].selected = true;
 }

</script>
</head>
<body onload="alert('refreshed page')">

<form name="Testform" action="">
 <select name="Auswahl" size="5" onchange="setAuswahl(document.Testform.Auswahl.selectedIndex)">
 <option>Goethe</option>
 <option>Schiller</option>
 <option>Guildo Horn</option>
 <option>Homer</option>
 <option>Fontane</option>
 </select>
 </form>

<script type="text/javascript">
  testOldSel();
 </script>
</body>
</html>

<html>
<head>
 <title>ich bin test1.htm</title>
 <script type="text/javascript">

function replaceMe()
 {
  var index=0;
  var mySel=window.location.hash;
  if (mySel!="")
  {
   index = mySel.replace(/#/,"");

}
  self.location.replace("./test2.htm#"+index);
 }

</script>
</head>
<body onload="window.setTimeout('replaceMe()',50)">
</body>
</html>

Grüsse,
Richard