Free Code > Glossy Scripts > Glossy Menus
Glossy Menus is a JavaScript+CSS solution for creating hierarchical "tree menus" on your site. The example menu shown below is taken straight from the site navigation code for Globalisk.com (those links over there —>). How to usePlace the JavaScript and CSS code somewhere on your site, and then reference them in the header of your documents as follows:
<link rel="stylesheet" type="text/css" href="glossymenus.css" />
<script type="text/javascript" src="glossymenus.js"></script> In your own site navigation JavaScript file (which you should reference after the Glossy code in the header of your documents), you can declare your site menu(s) as such:
var m0 = new GlossyMenu();
m0.addLink( "Home", "/" ); m0.addLink( "Blog", "http://globalisk.com/blog" ); var b2 = m0.addLink( "Blosics 2", "", "Addictive physics based game" ); b2.addLink( "Play the game", "/blosics2/", "Play Blosics 2" ); b2.addLink( "Play user Level Pack", "/blosics2/levelpack.html", "Play Blosics 2 Level Pack (levels created by Blosics users)" ); var obd = b2.addLink( "OBD's Levels", "/blosics2/obd.html", "OBD's Blosics 2 levels" ); var ch1 = obd.addLink( "Ch. 1: Inception", "/blosics2/obd.html#1" ); ch1.addLink( "Goldberg vs. Heisenberg", "/blosics2/obd1.html#1" ); // ...et cetera... In your site pages, place the menu rendering code wherever you want your menus to appear: <script type="text/javascript">
m0.print(); </script> Customizing your menusYou can redefine any/all styles as defined in the CSS file (it is recommended that you override them with your own stylesheets rather than alter the default styles in the source). You can also assign your own values to several JavaScript variables:
If you find this code useful, please consider making a donation.
Copyright © Globalisk. All rights reserved. |
|
|||||||||||||||||||||||||||