DHTML script
 

SimplytheBest
Scripts

ASP scripts
PERL scripts
PHP scripts
JavaScripts & Ajax
Snippets
Online scripts

Ajax, DHTML
& JavaScripts

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
Publisher list



 

Home > Scripts > DHTML scripts & JavaScripts > Menus > Switch menu script

 

Switch menu script

AUTHOR: Martial Boissonneault
TYPE: Freeware
BROWSERS: IE 5+, IE 6+, NS 6+

This menu allows you to open and close submenus on click. Upon opening of a submenu it automatically closes any open submenu.


EXAMPLE


1)
Insert this style command with the script in the <HEAD> section of the page or add to an existing CSS stylesheet if used.

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

2) Insert the following HTML code in the <BODY> section where you want the menu to appear in the page:

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

3) Define the style of the menu and the links in the <STYLE> command section:

<style type="text/css">
.menuOut {cursor:pointer; margin:2px; background-color:#0099cc; color:#000000; width:120px; border:1px solid #000000; padding:2px; text-align:center; font-family:arial; font-weight:bold;}
.menuOver {cursor:pointer; margin:2px; background-color:#000000; color:#0099cc; width:120px; border:1px solid #0099cc; padding:2px; text-align:center; font-family:arial; font-weight:bold;}
.submenu {width:115px; font-family:arial; font-size:11px; padding-left:5px;}
.submenu a {color:#000080; text-decoration:none; font-weight:bold;}
.submenu a:hover {color:#ff0000; text-decoration:none; font-style:oblique; font-weight:bold;}
</style>

4) Define the menu headers and the links in this section of the HTML code:

<!-- Menu start -->
<div id="cont">
<p id="menu1" class="menuOut" onclick="SwitchMenu('sub1')" onmouseover="ChangeClass('menu1','menuOver')" onmouseout="ChangeClass('menu1','menuOut')">SHAREWARE</p>
<div class="submenu" id="sub1" style="display:none;">
&#149; <a href="business.html" title="Business shareware">Business</a><br/>
&#149; <a href="graphics.html" title="Graphics shareware">Graphics</a><br/>
&#149; <a href="hobby.html" title="Hobby shareware">Hobby</a><br/>
&#149; <a href="programming.html" title="Programming shareware">Programming</a><br/>
&#149; <a href="utilities.html" title="Utilities shareware">Utilities</a><br/>
&#149; <a href="web_utilities.html" title="Internet utilities shareware">Web utilities</a>
</div>

<p id="menu2" class="menuOut" onclick="SwitchMenu('sub2')" onmouseover="ChangeClass('menu2','menuOver')" onmouseout="ChangeClass('menu2','menuOut')">SCRIPTS</p> 
<div class="submenu" id="sub2" style="display:none;">
&#149; <a href="cgi_scripts/cgi_scripts.html" title="CGI scripts">CGI scripts</a><br/>
&#149; <a href="scripts/dhtml_scripts.html" title="DHTML scripts & Javascripts">DHTML scripts</a>
</div>
and so forth...


That's all there is to it.

For more information you can also visit the getElementById.com web site.


[BACK] [TOP]

 


Copyright © 1997-2009 SimplytheBest Inc. Terms of Use and Legal Disclaimer.
All copyrights are acknowledged. All rights reserved.