Avatar billede krk Nybegynder
16. maj 2006 - 14:22 Der er 3 kommentarer og
1 løsning

tree menu

Hej
Jeg har fundet en menu som jeg godt kunne bruge til mit site, men jeg har lidt problemer med det. Denne menu har undermenuer til alle hoved-punkterne. Jeg vil gerne have at der IKKE er undermenuer til ex. det første hovedpunkt (Civils & Drainage), men at det bare var et link. Kan det lade sig gøre??

Jeg sender lidt kode med
menu.htm:
<script language="JavaScript">
// write Civils & Drainage Menu
if(page=='civ') {
openMenu('Civils & Drainage');
} else {
closeMenu('Civils & Drainage','civ');
}
// write Clothing Menu
if(page=='cloth') {
openMenu('Clothing');
} else {
closeMenu('Clothing','cloth');
}
</script>



jsmenu.js:
// Civils & Drainage Menu
if (page=='civ') {
thisMenu = new Array();
thisMenu[0] = new subMenu('Above Ground Plastics','above.html');
thisMenu[1] = new subMenu('Below Ground Plastics','below.html');
thisMenu[2] = new subMenu('Block Paving','paving.html');
}
Avatar billede krk Nybegynder
16. maj 2006 - 14:45 #1
Sig til hvis I skal have hele koden
Avatar billede roenving Novice
17. maj 2006 - 10:50 #2
Jeg kan i hvert fald ikke gennemskue noget ...
Avatar billede krk Nybegynder
17. maj 2006 - 10:54 #3
okay, jeg sender mere kode. Håber det giver mere mening :-)
menu.htm:
<script language='JavaScript' src='jsmenu/jsmenu.js'></script>
<script language='JavaScript'>
//*********************************************
// Tree Menu Copyright Simon Rycroft
// For more scripts go to:
// http://www.d-zineworx.co.uk
//*********************************************
// opens menu section - do not alter
function openMenu(cat) {
this.cat = cat;
document.write('<span class = "level1">');
document.write('<a href = "' + thisPage + '?page=null" target="_self">');
if (lev1img=='yes') {
document.write('<img src="' + imgPath + lev1OpName +'" width="' + lev1OpWidth + '" height="' + lev1OpHeight + '"border="0">');
}
document.write(cat + '</a><span><br>');
for (x=0;x<thisMenu.length;x++){
document.write('<span class = "level2">');
if (lev2img=='yes') {
document.write('<img src="' + imgPath + lev2Name +'" width="' + lev2Width + '" height="' + lev2Height + '">');
}
if (lev2Char=='yes') {
document.write(bullet);
}
document.write('<a href="' + linka + thisMenu[x].linkb + '">' + thisMenu[x].name + '</a><span><br>');
}
}
// closes menu section - do not alter
function closeMenu(cat,pass) {
this.cat = cat;
this.pass = pass;
document.write('<span class = "level1">');
document.write('<a href = "' + thisPage + '?page='+pass+'" target="_self">');
if (lev1img=='yes') {
document.write('<img src="' + imgPath + lev1ClosName +'" width="' + lev1ClosWidth + '" height="' + lev1ClosHeight + '"border="0">');
}
document.write(cat + '</a><span><br>');
}
</script>
</head>
<body bgcolor="#FFCC00" text="#000000">
<script language="JavaScript">
// write Civils & Drainage Menu
if(page=='civ') {
openMenu('Civils & Drainage');
} else {
closeMenu('Civils & Drainage','civ');
}
// write Clothing Menu
if(page=='cloth') {
openMenu('Clothing');
} else {
closeMenu('Clothing','cloth');
}
// write Decorating Menu
if(page=='dec') {
openMenu('Decorating');
} else {
closeMenu('Decorating','dec');
}

// write kate
if(page=='kate') {
openMenu('kate');
} else {
closeMenu('kate','kate');
}

</script>


jsmenu.js:
// *****************************************************************************
// **                                SETTINGS                                **
// *****************************************************************************

// 'linka' use this if part of the URL is the same in ALL the links
// In this example all the files are in a subfolder called 'pages'
linka='pages/';

// the filename of the page the menu appears in eg 'menu.html'
thisPage='menu.html';

// Do you want to use images for the category bullets?
// If so then specify the path to your images folder from the menu page
imgPath='images/';

// do you want to use images for the category bullets?
lev1img='yes';                    // insert yes or no

// give image names and dimensions
lev1OpName='open.gif';            // open image name
lev1OpHeight='10';                // image height
lev1OpWidth='10';                // image width

lev1ClosName='closed.gif';        // closed image name
lev1ClosHeight='10';            // image height
lev1ClosWidth='10';                // image width

// do you want to use images for the sub-category bullets?
lev2img='yes';        // insert yes or no

// give image names and dimensions
lev2Name='bullet.gif';            // image name
lev2Height='10';                // image height
lev2Width='16';                    // image width

// do you want to use a text character for the sub-category bullets?
lev2Char='no';        // insert yes or no

// set bullet character for level 2 bullets
bullet = '&#155; ';

// base target - the frame that the links are targetting
base = 'main';

// *****************************************************************************
// **                            END OF SETTINGS                            **
// *****************************************************************************

// pulls 'page' variable out of URL - do not alter
    var x = 0
    page = location.search.substr(1).split("?")
    for (x=0;x<=page.length;x++) {
        eval(page)
        }
page = escape(page);
page = page.slice(7);

// do not alter this bit
function subMenu(name,linkb) {
this.name = name;
this.linkb = linkb;
}
document.write('<BASE target="' + base + '">');

// *****************************************************************************
// **                            BUILD MENU DATA                            **
// *****************************************************************************

// Civils & Drainage Menu
if (page=='civ') {
thisMenu = new Array();
thisMenu[0] = new subMenu('Above Ground Plastics','above.html');
thisMenu[1] = new subMenu('Below Ground Plastics','below.html');
thisMenu[2] = new subMenu('Block Paving','paving.html');
}

// Clothing Menu
if (page=='cloth') {
thisMenu = new Array();
thisMenu[0] = new subMenu('Hats','hats.html');
thisMenu[1] = new subMenu('Gloves','gloves.html');
thisMenu[2] = new subMenu('Coats','coats.html');
}

// Decorating Menu
if (page=='dec') {
thisMenu = new Array();
thisMenu[0] = new subMenu('Brushes','brushes.html');
thisMenu[1] = new subMenu('Paint','paint.html');
thisMenu[2] = new subMenu('Rollers','rollers.html');
}
Avatar billede krk Nybegynder
23. maj 2006 - 09:48 #4
lukker
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester