Hallo Torsten,
Ich hab ein Script, das aus einer Definition ein Inhaltsverzeichnis erstellt,
daß dann in einem Frame ausgegeben wird. Die entsprechenden zusatzfunktionen sind relativ
leich hinzuzufügen.
Die wichtigste Datei daten.js
/*
(c)Daniel Thoma
E-Mail: dthoma@gmx.net
Wer diesen Kommentar entfernt verliert seine Webguruwürde.
*/
function menu()
{
var ebene = 0;
var code = "";
for(var a = 0; a < inhalt.length; a++)
{
if(inhalt[a].art == "kapitel")
{
code += "<LI>" + inhalt[a].title + "</LI>";
code += "<UL>" + submenu(inhalt[a].files) + "</UL>";
}
if(inhalt[a].art == "file")
{
code += "<LI><A href="" + inhalt[a].name + "" target="content">" + inhalt[a].title + "</A></LI>";
}
}
return code;
}
function submenu(files)
{
var code = "";
for(var a = 0; a < files.length; a++)
{
if(files[a].art == "kapitel")
{
code += "<LI>" + files[a].title + "</LI>";
code += "<UL>" + submenu() + "</UL>";
}
if(files[a].art == "file")
{
code += "<LI><A href="" + files[a].name + "" target="content">" + files[a].title + "</A></LI>";
}
}
return code;
}
function kapitel(title)
{
this.title = title;
this.files = new Array();
this.art = "kapitel";
}
function file(title, name)
{
this.title = title;
this.name = name;
this.art = "file";
}
//Hier beginnt die Definition der Dateien
var inhalt = new Array();
inhalt[0] = new kapitel("kapitel 1");
inhalt[0].files[0] = new file("nr 1","doc1.html");
inhalt[0].files[1] = new file("nr 2","doc2.html");
inhalt[1] = new kapitel("kapitel 2");
inhalt[1].files[0] = new file("nr 1","doc3.html");
inhalt[1].files[1] = new file("nr 2","doc4.html");
Die Datei menu.html
<html>
<head>
<title>menu</title>
<script src="daten.js" type="text/javascript" language="JavaScript1.1">
</script>
</head>
<body>
<nobr>
<script>
document.open();
document.write(menu());
document.close();
</script>
</nobr>
</body>
</html>
Die datei index.html
<HTML>
<head>
<title>docu</title>
</head>
<frameset cols="100,*">
<frame name="menu" src="menu.html">
<frame name="content" src="start.html">
</frameset>
</HTML>
Ich habe ein ähnliches Script auch als DHTML-Navigationsbaum. (Wie der Windows Explorer)
Tschüs
Daniel