collapsible menu tree

DHTML scripts DHTML script
 

DHTML script
categories

Animation
Background
Bookmarks
Buttons
Calculators
Cookies
Data handling
E-mail
Enhancements
Forms
Image rotation
Menus
Messages
Miscellaneous
Music
Password protection
Redirection
Scrollers
Tables
Time & date
Windows

Publishers

Add script
Account login

 

Home > Scripts > DHTML scripts & JavaScripts > Menus > Collapsible menu tree

 

Collapsible menu tree

AUTHOR: Tomer Shiran
TYPE: Freeware
BROWSERS: IE 4+, IE 5+, IE 6+, NS 4+, NS 6+

A collapsible menu tree that contains links and sub links. This script includes a cookie which determines if a visitor has been here before and remembers the setting of the expanded or collapsed menu trees.


EXAMPLE

Click on the folder icons to expand and collapse the menus.


1)
Insert this script in the <HEAD> section of the page.

then copy (CTRL-C) & paste (CTRL-V)

 

2) Insert this script in the <BODY> section where you want the menu tree to appear in the page.

then copy (CTRL-C) & paste (CTRL-V)

 

3) Define the headers and the links of your menu tree in this section of the first script:

function makeDatabase() {
outline = new makeArray(6)
// the number of outlines plus one

outline[0] = new item(true, 'SimplytheBest.net', 0)
outline[1] = new item(false, '<A HREF="shareware.html">Shareware & Freeware</A>', 1)
outline[2] = new item(true, 'Scripts', 1)
outline[3] = new item(false, '<A HREF="javascripts/dhtml_scripts.html">DHTML Scripts</A>', 2)
outline[4] = new item(false, '<A HREF="cgiscripts/cgiscripts.html">CGI Scripts</A>', 2)
outline[5] = new item(false, '<A HREF="info/index.html">Information library</A>', 1)

4) Define where the images are stored in this section of the first script:

function setImages() {
for (var i = 0; i < outline.length; ++i) {
if (outline[i].state)
if (outline[i].parent) 
if (outline[i + 1].state) 
outline[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="images/exploded.gif" BORDER=0></A>'
else 
outline[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="images/collapsd.gif" BORDER=0></A>'
else 
outline[i].pic = '<IMG SRC="images/child.gif" BORDER=0>'

5) Customize the font style and the indent spacing for each nesting in this section of the second script:

document.write('<PRE><font face=arial size=2>')
for (var i = 0; i < outline.length; ++i) {
if (outline[i].state) {
for (var j = 0; j < outline[i].depth * 5; ++j) { 
// place five spaces for each nesting
document.write(' ')
}

Copy the below images by right clicking on them and choosing "Save picture as", or use your own images.


[BACK] [TOP]

 

BLOGS - BOOKMARKS - FONTS - FRIENDS - GAMES - HEADLINES
MUSIC - PIXELS - SCRIPTS - SOFTWARE - SOUNDS - WEB SEARCH

 


Copyright © 1997-2008 SimplytheBest Inc. Legal Disclaimer.
All copyrights acknowledged. All rights reserved.