Demonstration |
IntroductionUse this script to create Explorer-like tree-menus (see examples on the left). You can create floating* and non-floating menus. The script was tested with the following operating systems and browsers:
If you use another browser or operating system, this script may not work for you - sorry. * With Safari 1 (Mac OS X) performance was poor, i.e. floating speed was slow. With IE 5 (Mac OS X) floating didn't work properly. UsageFirst, insert this line into your HTML body where you want the menu to appear:<script language="JavaScript" src="treemenu.js"></script>Then create a new instance of the TREEMENU-class: var menu = new TREEMENU();If you want to open all folders at start (completely open tree), use this syntax instead: var menu = new TREEMENU(true);By the way, you can create as many menus as you want. Now insert your menu items (level, text, [URL], [target], [JavaScript]):
menu.entry(1, "item 1", "page1.htm", "parent.main");
menu.entry(2, "item 1.1", "page1-1.htm", "blank");
menu.entry(2, "item 1.2", "", "", "alert('You clicked menu item 1.2')");
...
Finally, adapt the configuration to your needs and create the menu: menu.floating = true; menu.width = 200; menu.bgColor = "#F0F0F0"; menu.itemWrap = true; menu.itemBold = true; ... menu.create();Please have a look at the script (configuration section) for more detailed information. Inside your HTML code, you can also use the function jumpTo() to link menu items externally. Example: Go to menu item 1.3.2.1 <a href="javascript:menu.jumpTo(1, 3, 2, 1)">Go to menu item 1.3.2.1</a>It's also possible to open or close the complete tree-menu with the functions open() and close(). Example: open all | close all <a href="javascript:menu.open()">open all</a> <a href="javascript:menu.close()">close all</a>Hint: You should have a look at the source code of this page to see how tree-menus are created. ;-) |