Warum funktioniert Code nur einmal im Frame?

melli2021

Grünschnabel
Hallöchen, ich hätte mal wieder ein Frage.

habe mir übers Internet nen Code für nen Hierarchical menu generieren lassen!

Hab den genau unter den Button eingefügt. Funktioniert auch alles wunderbar.

Nun wollte ich in dem Frame noch ein Button einsetzen und noch einmal den Code und nun funktioniert es nicht mehr. Immer wenn man auf den Pfeil klickt kommt die Meldung "Das Objekt unterstützt diese Eigenschaft oder Methode nicht. nehme ich den Code vom 2. Button wieder heraus, funktioniert es wieder. Unterteile ich diesen Frame und habe ja somit 2 Frames funktioniert es auch ganz normal. Is in dem Code irgend eine Einstellung die besagt, dass man diesen Code nur einmal in einem Frame anwenden darf oder?

P.S. Ich habe nicht wirklich ne Ahnung davon....

Unter http://paidmailer.trabant-seite.de kann man das sehen. Es geht um den linken Frame und so wie dort der Butoton "deutsche Paidmailer" ist so möchte ich noch mehrere Dieser Button in diesen Frame einauen, halt auch mit dem Hierarchic Menu-Code. Hier ist der Code dazu.

Ich weiß einiges ist ncoh nicht komplett ausgefüllt, kommt noch. Sollte ja erst nur nen Test sein

Code:
<script> 
// CREDITS: 
// Hierarchical Menu Version 2.01 by Urs Dudli and Peter Gehrig 
// Copyright (c) 2002 Peter Gehrig and Urs Dudli. All rights reserved. 
// Permission given to use the script provided that this notice remains as is. 
// Additional scripts can be found at http://www.24fun.com. 
// info@24fun.ch 
// 2/22/2002 
// IMPORTANT: 
// If you add this script to a script-library or script-archive 
// you have to add a link to http://www.24fun.com on the webpage 
// where this script Script will be running. 
var verspacetoplevel=5 
var verspacesublevel=2 
var horspace=3 
var textdeco="none" 
var minusimg=new Image() 
minusimg.src="../images/arrowdown.gif" 
var plusimg=new Image() 
plusimg.src="../images/arrowup.gif" 
var plusminusimgsrc=plusimg.src 
var content="" 
var fnttop="comic sans ms" 
var fnttopsize=11 
var fnttopcolor="red" 
var fnttopweight="bold" 
var fntsub="comic sans ms" 
var fntsubsize=10 
var fntsubcolor="blue" 
var fntsubweight="bold" 
var i_level=new Array(0,1,1,1,1,1,1,1,1) 
var i_url=new Array("http://paidmailer.trabant-seite.de/Seiten/deuueber.htm","http://paidmailer.trabant-seite.de/Seiten/eurosmailer.html","http://","http://","http://","http://","http://","http://paidmailer.trabant-seite.de/Seiten/aloracs.htm","http://paidmailer.trabant-seite.de/Seiten/weiterePaidmailer.htm") 
var i_text=new Array("ÜBERSICHT","Eurosmailer","BannisDukatenportal","BonusAndCash","Geldspeicher","Moneyportal","Werbebote","Aloracs","weitere Mailer") 
var i_target=new Array("seite5","seite5","seite5","_blank","_blank","_blank","_blank","seite5","seite5") 
var whichi_opened=-1 
var i_opened=false 
var hassubmenus=false 
var istoppageitem=true 
var ie=document.all?1:0 
var ns6=document.getElementById&&!document.all?1:0 
var ns4=document.layers?1:0 
function closesublevels() { 
plusminusimgsrc=plusimg.src 
content="" 
content+="<table border=0 cellpadding=0 cellspacing="+verspacesublevel+">" 
for (i=0;i<=i_level.length;i++) { 
hassubmenus=false 
if (i_level[i]==0) { 
var iplus=i+1 
if ((iplus<=i_level.length) && (i_level[iplus]==1)) { 
hassubmenus=true 
} 
if (hassubmenus) { 
if (!istoppageitem) { 
content+="<tr><td colspan=2><img src='emptypixel.gif' height="+verspacetoplevel+"></td></tr>" 
} 
istoppageitem=false; 
content+="<tr valign=middle>" 
content+="<td>" 
content+="<a href='javascript:opensublevels("+i+")'>" 
content+="<img src='"+plusminusimgsrc+"' border=0 hspace="+horspace+"></a>" 
content+="</td>" 
content+="<td>" 
content+="<a href='javascript:opensublevels("+i+")' style='text-decoration:"+textdeco+";font-family:"+fnttop+";font-size:"+fnttopsize+"pt;color:"+fnttopcolor+";font-weight:"+fnttopweight+"'>" 
content+=i_text[i] 
content+="</a></td></tr>" 
} 
else { 
if (!istoppageitem) { 
content+="<tr><td colspan=2><img src='emptypixel.gif' height="+verspacetoplevel+"></td></tr>" 
} 
istoppageitem=false; 
content+="<tr valign=middle><td></td>" 
if (i_url[i]!="#" && i_url[i]!="" && i_url[i]!="http://" && i_url[i].indexOf("@")<0) { 
content+="<td><a href='"+i_url[i]+"' target='"+i_target[i]+"' style='text-decoration:"+textdeco+";font-family:"+fnttop+";font-size:"+fnttopsize+"pt;color:"+fnttopcolor+";font-weight:"+fnttopweight+"'>" 
} 
else if (i_url[i].indexOf("@")>0) { 
content+="<td><a href='mailto:"+i_url[i]+"' style='text-decoration:"+textdeco+";font-family:"+fnttop+";font-size:"+fnttopsize+"pt;color:"+fnttopcolor+";font-weight:"+fnttopweight+"'>" 
} 
else { 
i_url[i]="#" 
content+="<td><a href='"+i_url[i]+"' style='text-decoration:"+textdeco+";font-family:"+fnttop+";font-size:"+fnttopsize+"pt;color:"+fnttopcolor+";font-weight:"+fnttopweight+"'>" 
} 
content+=i_text[i] 
content+="</a></td></tr>" 
} 
} 
} 
content+="</table>" 
istoppageitem=true; 
whichi_opened=-1 
if (ie) { 
menu.innerHTML=content 
} 
if (ns6) { 
document.getElementById("menu").innerHTML=content 
} 
if (ns4) { 
document.menutop.document.menu.document.write(content) 
document.menutop.document.menu.document.close() 
} 
} 
function opensublevels(thisiopened) { 
if (whichi_opened==thisiopened) { 
openurl() 
closesublevels() 
} 
else { 
whichi_opened=thisiopened 
content="" 
content+="<table border=0 cellpadding=0 cellspacing="+verspacesublevel+">" 
for (i=0;i<=i_level.length;i++) { 
if (i_level[i]==0) { 
if (thisiopened==i) {i_opened=true} 
else {i_opened=false} 
var iplus=i+1 
if ((iplus<=i_level.length) && (i_level[iplus]==1)) {hassubmenus=true} 
else {hassubmenus=false} 
if (i_opened) {plusminusimgsrc=minusimg.src} 
else {plusminusimgsrc=plusimg.src} 
if (!istoppageitem) { 
content+="<tr><td colspan=2><img src='emptypixel.gif' height="+verspacetoplevel+"></td></tr>" 
} 
istoppageitem=false; 
content+="<tr valign=middle><td>" 
if (hassubmenus) { 
content+="<a href='javascript:opensublevels("+i+")'>" 
content+="<img src='"+plusminusimgsrc+"' border=0 hspace="+horspace+"></a>" 
} 
content+="</td>" 
content+="<td><a href='javascript:opensublevels("+i+")' style='text-decoration:"+textdeco+";font-family:"+fnttop+";font-size:"+fnttopsize+"pt;color:"+fnttopcolor+";font-weight:"+fnttopweight+"'>" 
content+=i_text[i] 
content+="</a></td></tr>" 
} 
else if (i_level[i]==1 && i_opened){ 
content+="<tr valign=middle><td> </td>" 
if (i_url[i]!="#" && i_url[i]!="" && i_url[i]!="http://" && i_url[i].indexOf("@")<0) { 
content+="<td><a href='"+i_url[i]+"' target='"+i_target[i]+"' style='text-decoration:"+textdeco+";font-family:"+fntsub+";font-size:"+fntsubsize+"pt;color:"+fntsubcolor+";font-weight:"+fntsubweight+"'>" 
} 
else if (i_url[i].indexOf("@")>0) { 
content+="<td><a href='mailto:"+i_url[i]+"' style='text-decoration:"+textdeco+";font-family:"+fntsub+";font-size:"+fntsubsize+"pt;color:"+fntsubcolor+";font-weight:"+fntsubweight+"'>" 
} 
else { 
i_url[i]="#" 
content+="<td><a href='"+i_url[i]+"' style='text-decoration:"+textdeco+";font-family:"+fntsub+";font-size:"+fntsubsize+"pt;color:"+fntsubcolor+";font-weight:"+fntsubweight+"'>" 
} 
content+=i_text[i] 
content+="</a></td></tr>" 
} 
} 
content+="</table>" 
if (ie) { 
menu.innerHTML=content 
} 
if (ns6) { 
document.getElementById("menu").innerHTML=content 
} 
if (ns4) { 
document.menutop.document.menu.document.write(content) 
document.menutop.document.menu.document.close() 
} 
istoppageitem=true; 
openurl() 
} 
} 
function openurl() { 
var selectedtarget=i_target[whichi_opened] 
var selectedurl=i_url[whichi_opened] 
if (selectedurl!="#" && selectedurl!="" && selectedurl!="http://" && selectedurl.indexOf("@")<0) { 
document.flink.target=selectedtarget 
document.flink.action=selectedurl 
document.flink.submit() 
} 
else if (selectedurl.indexOf("@")>0) { 
selectedurl="mailto:"+selectedurl 
document.flink.target=selectedtarget 
document.flink.action=selectedurl 
document.flink.submit() 
} 
} 
init() 
function init() { 
istoppageitem=true; 
content="" 
content+="<table border=0 cellpadding=0 cellspacing="+verspacesublevel+">" 
for (i=0;i<=i_level.length;i++) { 
if (i_level[i]==0) { 
var iplus=i+1 
if ((iplus<=i_level.length) && (i_level[iplus]==1)) {hassubmenus=true} 
else {hassubmenus=false} 
if (!istoppageitem) { 
content+="<tr><td colspan=2><img src='emptypixel.gif' height="+verspacetoplevel+"></td></tr>" 
} 
istoppageitem=false; 
content+="<tr valign=middle><td>" 
if (hassubmenus) { 
content+="<a href='javascript:opensublevels("+i+")'>" 
content+="<img src='"+plusminusimgsrc+"' border=0 hspace="+horspace+"></a>" 
} 
content+="</td>" 
content+="<td><a href='javascript:opensublevels("+i+")' style='text-decoration:"+textdeco+";font-family:"+fnttop+";font-size:"+fnttopsize+"pt;color:"+fnttopcolor+";font-weight:"+fnttopweight+"'>" 
content+=i_text[i] 
content+="</a></td></tr>" 
} 
else if (i_level[i]==1){ 
content+="<tr valign=middle><td> </td>" 
content+="<td><a href='"+i_url[i]+"' target='"+i_target[i]+"' style='text-decoration:"+textdeco+";font-family:"+fntsub+";font-size:"+fntsubsize+"pt;color:"+fntsubcolor+";font-weight:"+fntsubweight+"'>" 
content+=i_text[i] 
content+="</a></td></tr>" 
} 
} 
content+="</table>" 
istoppageitem=true; 
if (ie || ns6) { 
document.write('<span id="menu" style="position:relative">'+content+'</span>') 
document.close() 
} 
else if (ns4) { 
document.write('<ilayer name="menutop">') 
document.write('<layer name="menu">'+content+'</layer>') 
document.write('</ilayer>') 
document.close() 
} 
else { 
oldbrowser() 
} 
} 
function oldbrowser() { 
istoppageitem=true; 
content="" 
content+="<table border=0 cellpadding=0 cellspacing="+verspacesublevel+">" 
for (i=0;i<=i_level.length;i++) { 
if (i_level[i]==0) { 
var iplus=i+1 
if ((iplus<=i_level.length) && (i_level[iplus]==1)) {hassubmenus=true} 
else {hassubmenus=false} 
if (!istoppageitem) { 
content+="<tr><td colspan=2><img src='emptypixel.gif' height="+verspacetoplevel+"></td></tr>" 
} 
istoppageitem=false; 
content+="<tr valign=middle><td>" 
if (hassubmenus) { 
content+="<img src='"+plusminusimgsrc+"' border=0 hspace="+horspace+">" 
} 
content+="</td>" 
content+="<td><a href='"+i_url[i]+"' target='"+i_target[i]+"'><font size=3 face="+fnttop+" color="+fnttopcolor+">" 
content+=i_text[i] 
content+="</font></a></td></tr>" 
} 
else if (i_level[i]==1){ 
content+="<tr valign=middle><td> </td>" 
content+="<td><a href='"+i_url[i]+"' target='"+i_target[i]+"'><font size=2 face='"+fntsub+"' color="+fntsubcolor+">" 
content+=i_text[i] 
content+="</font></a></td></tr>" 
} 
} 
content+="</table>" 
document.write(content) 
document.close() 
} 
function reloadpage() { 
location.reload(true) 
} 
if (ns4 || ns6 || ie) { 
window.onload=closesublevels 
} 
if (ns4 || ns6 || ie) { 
window.onresize=reloadpage 
} 
</script><form name="flink" target="_blank" action="http://www.24fun.com"> 
<input type=hidden value=""> 
</form>

Hoffe mir kann jemand helfen!

Gruß und Danke im Voraus, Melli
 
melli2021 hat gesagt.:
P.S. Ich habe nicht wirklich ne Ahnung davon....
Wir sind nicht dazu da, dein Codesample dir begreiflich zu machen. Setze dich hinter dem Code, versuche ihn zu verstehen und dementsprechend anzupassen.
Haben wir zuviel Zeit oder wie?!
 
Hallo...

wenn man in einem document nach beendetem Laden eine write()-Anweisung ausführt wie in deinem Fall, wird der bisherige Inhalt überschrieben....inklusive Skriptcode...deshalb geht es nur 1 mal, weil es beim 2.mal kein Skript mehr gibt.

Ich würd vorschlagen, du wirfst das ganze Ding weg und schaust dir mal das "Basic-DHTML-Menu" an: http://www.tutorials.de/forum/showthread.php?t=24983

Das macht abgesehen von dem wechselnden Pfeil dasselbe, braucht aber nur einen Bruchteil an Code:)

Das mit dem Pfeil kriegen wir gemeinsam auch noch hin ;)
 
@krypthonas

Es geht ja wohl auch nen bissl freundlicher..... Ich wollte nur wissen warum des nicht so funktioniert wie ich es wollte. Ich wollte keine stundenlangen Sitzungen beantragen... Ich wusste nicht, dass dieses Forum nur für Menschen ist die Profis in diesem Bereich sind!

@Sven Mintel

Danke für die Hilfe, aber ich habe nun schon in einem anderen Forum Rat bekommen.
Dort wurde mir gleich nen neues Script geschrieben (habe ich nicht verlangt und hätte ich auch von niemanden verlangt) und nun alles so wie ich es haben wollte. Trotzdem Danke
 
Wenn dein Problem gelöst ist, dann markiere deine zukünftigen Themen bitte auch als erledigt.

Vielen Dank ;)
 
Zurück