Not too easy for me but, this way I learn something too
. Still haven't figured out how to extend the persistence to these added levels.
OK, here we go, add to the style section (this is where you can change the look of these new elements):
Code:
.submenutitle {
cursor:pointer;
margin-top:4px;
margin-bottom: 2px;
background-color:#ECECFF;
color:#000000;
width:110px;
padding:2px;
text-align:center;
font-weight:bold;
font-size:smaller;
/*/*/border:1px solid #000000;/* */
}
.ssubmenu{
margin-bottom: 0.5em;
}
Just below the line that says:
Code:
document.write('.submenu{display: none;}\n')
add this line:
Code:
document.write('.ssubmenu{display: none;}\n')
Just below the SwitchMenu function (just above the line that says "function get_cookie(Name) {") add this function:
Code:
function SwitchsubMenu(obj){
if(document.getElementById){
var sel = document.getElementById(obj);
var sar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
if(sel.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<sar.length; i++){
if (sar[i].className=="ssubmenu") //DynamicDrive.com change
sar[i].style.display = "none";
}
sel.style.display = "block";
}else{
sel.style.display = "none";
}
}
}
Now in the markup (HTML section), here is how things will look, I added two inner switch menus so you get the idea, one where you said you wanted it and one at the end of the existing 'Site Menu' listings. Following this format, you can add as many of these as you like. Example HTML:
HTML Code:
<!-- Keep all menus within masterdiv-->
<div id="masterdiv">
<div class="menutitle" onclick="SwitchMenu('sub1')">Site Menu</div>
<span class="submenu" id="sub1">
<div class=submenutitle onclick="SwitchsubMenu('ssub1')">What's New</div>
<span class=ssubmenu id=ssub1>
- <a href="http://www.statestreetblues.com/">State Street Blues Stroll!</a><br>
- <a href="http://www.mediajazzbynight.com/">Media Jazz by Night!</a>
</span>
- <a href="../hot.htm">What's hot</a><br>
- <a href="../revised.htm">Revised Scripts</a><br>
- <a href="../morezone/">More Zone</a>
<div class=submenutitle onclick="SwitchsubMenu('ssub2')">Yet More Choices</div>
<span class=ssubmenu id=ssub2>
- <a href="http://www.yahoo.com/">Yahoo!</a>
</span>
</span>
<div class="menutitle" onclick="SwitchMenu('sub2')">FAQ/Help</div>
<span class="submenu" id="sub2">
- <a href="../notice.htm">Usage Terms</a><br>
- <a href="../faqs.htm">DHTML FAQs</a><br>
- <a href="../help.htm">Scripts FAQs</a>
</span>
<div class="menutitle" onclick="SwitchMenu('sub3')">Help Forum</div>
<span class="submenu" id="sub3">
- <a href="http://www.codingforums.com">Coding Forums</a><br>
</span>
<div class="menutitle" onclick="SwitchMenu('sub4')">Cool Links</div>
<span class="submenu" id="sub4">
- <a href="http://www.javascriptkit.com">JavaScript Kit</a><br>
- <a href="http://www.freewarejava.com">Freewarejava</a><br>
- <a href="http://www.cooltext.com">Cool Text</a><br>
- <a href="http://www.google.com">Google.com</a>
</span>
<img src="files/about_off.gif" onclick="SwitchMenu('sub5')"><br>
<span class="submenu" id="sub5">
- <a href="http://www.dynamicdrive.com/link.htm">Link to DD</a><br>
- <a href="http://www.dynamicdrive.com/recommendit/">Recommend Us</a><br>
- <a href="http://www.dynamicdrive.com/contact.htm">Email Us</a><br>
</span>
</div>
Perhaps someone else who is more familiar with cookies than I will jump in here and help us expand the persistence part of this script to include these new ssub menus.
Bookmarks