So_Cute
08-14-2005, 05:44 AM
http://www.dynamicdrive.com/dynamicindex1/switchmenu.htm
I found a modification of the Script Menu which allows you to have top level items in the menu.
Sure thing:
In your code, find the function SwitchMenu and replace it with this:
function SwitchMenu(obj, addr){
if(document.getElementById){
if (obj!=0)var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
if(obj==0 || el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
if (obj!=0)el.style.display = "block";
}else{
if (obj!=0)el.style.display = "none";
}
}
if (addr) parent.location.href=addr
}
Then, for your menu, it should look like this:
<div class="menutitle" onclick="SwitchMenu(0, './test2.html')" onMouseOver="this.className='menutitle2'" onMouseOut="this.className='menutitle'">Home</div>
<div class="menutitle" onclick="SwitchMenu('sub2')" onMouseOver="this.className='menutitle2'" onMouseOut="this.className='menutitle'">Industrial</div>
<span class="submenu" id="sub2">
<a href="http://www.sequal.com/industrialoxygenproducts.htm" target="mainWindow">Oxygen</a><br>
<a href="http://www.sequal.com/industrialnitrogengproducts.htm" target="mainWindow">Nitrogen</a><br>
<a href="http://www.sequal.com/industrialairdryingproducts.htm" target="mainWindow">Air Dryer</a><br>
</span>
For the ones that will not expand, the onClick becomes SwitchMenu(0, 'theurlitislinkedto.html'). That's it! The onMouseover and onMouseOut are just a way to have (obviously) mouseover effects.
The modification works great and does just what I wanted, except that I don't know how to set the target for a top level link. Some top level items will need to open in an iframe on the same page (target="main") and some will need to open in a new window (target="_blank").
Can someone help me please? I'm a total dork when it comes to Javascript!
I found a modification of the Script Menu which allows you to have top level items in the menu.
Sure thing:
In your code, find the function SwitchMenu and replace it with this:
function SwitchMenu(obj, addr){
if(document.getElementById){
if (obj!=0)var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
if(obj==0 || el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
if (obj!=0)el.style.display = "block";
}else{
if (obj!=0)el.style.display = "none";
}
}
if (addr) parent.location.href=addr
}
Then, for your menu, it should look like this:
<div class="menutitle" onclick="SwitchMenu(0, './test2.html')" onMouseOver="this.className='menutitle2'" onMouseOut="this.className='menutitle'">Home</div>
<div class="menutitle" onclick="SwitchMenu('sub2')" onMouseOver="this.className='menutitle2'" onMouseOut="this.className='menutitle'">Industrial</div>
<span class="submenu" id="sub2">
<a href="http://www.sequal.com/industrialoxygenproducts.htm" target="mainWindow">Oxygen</a><br>
<a href="http://www.sequal.com/industrialnitrogengproducts.htm" target="mainWindow">Nitrogen</a><br>
<a href="http://www.sequal.com/industrialairdryingproducts.htm" target="mainWindow">Air Dryer</a><br>
</span>
For the ones that will not expand, the onClick becomes SwitchMenu(0, 'theurlitislinkedto.html'). That's it! The onMouseover and onMouseOut are just a way to have (obviously) mouseover effects.
The modification works great and does just what I wanted, except that I don't know how to set the target for a top level link. Some top level items will need to open in an iframe on the same page (target="main") and some will need to open in a new window (target="_blank").
Can someone help me please? I'm a total dork when it comes to Javascript!