Så har jeg lavet første udkast (kalder det udkast for indtil videre har jeg jo ikke kunne lave det du ønskede). Eksemplet indeholder 3 Menu'er hver især indeholdende Hovedmenuer. Det er meget simpelt at tilføje nye menuer nu, du skal bare følge det mønster de andre følger (med id'erne og deres onclick kald, du skal også huske at kalde initMenu med menu id'erne i onload event'en for at menuerne bliver intialiseret korrekt).
Som du kan se er koden igen blevet omstruktureret, men igen for at det er nemmere at overskue.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<META HTTP-EQUIV="Expires" CONTENT="Fri, Jun 12 1981 08:20:00 GMT">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="content-type" content="text/html;charset=iso-8859-1">
<META HTTP-EQUIV="imagetoolbar" content="no">
<META HTTP-EQUIV="Content-language" content="dan">
<META NAME="robots" content="all">
<title>MENU</title>
<script type="text/javascript">
var status;
var cookieLifeTime = 7; //In days. -1 is zero days and the cookies will disappear when the user logs off
function initMenu(menuName)
{
var cook = getCookie(menuName);
if(cook == null)
status = 1;
else
status = (cook == "1") ? 1 : 0;
setMenuVisibility(menuName, status);
}
function menuNav(menuName)
{
var cook = getCookie(menuName);
status = (cook == "1") ? 0 : 1;
setMenuVisibility(menuName, status);
}
function setMenuVisibility(menuName, status)
{
if(status == 0) //Closed
{
document.getElementById(menuName).style.display='none';
document.getElementById(menuName + "c").style.display='block';
}
else //Open
{
document.getElementById(menuName).style.display='block';
document.getElementById(menuName + "c").style.display='none';
}
createCookie(menuName, status, cookieLifeTime);
}
function createCookie(name, value, days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else
var expires = "";
if(days != -1)
document.cookie = name+"="+value+expires;
else
document.cookie = name+"="+value;
}
function getCookie( name )
{
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 )
return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 )
end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
</script>
</head>
<body onload="initMenu('menu1'); initMenu('menu2'); initMenu('menu3');">
<form name="frmMenuAdm" method="post" action="/" id="frmMenuAdm">
<div id="menu1" class="divmenuhead close menuframe" onclick="menuNav('menu1');"><span style="padding-left: 5px; font-weight: bold;">Administrér</span>
<div class="divmenutopcat" onclick="location.href='/newmainarea.asp'" onmouseover="this.className='divmenutopcatover';" onmouseout="this.className='divmenutopcatout';"><span style="padding-left: 8px;">Opret hovedområde</span></div>
<div class="divmenutopcat" onclick="location.href='/newtopcat.asp'" onmouseover="this.className='divmenutopcatover';" onmouseout="this.className='divmenutopcatout';"><span style="padding-left: 8px;">Opret hovedkategori</span></div>
<div class="divmenutopcat" onclick="location.href='/newsubcat.asp'" onmouseover="this.className='divmenutopcatover';" onmouseout="this.className='divmenutopcatout';"><span style="padding-left: 8px;">Opret underkategori</span></div>
</div>
<div id="menu1c" class="divmenuhead open menuframe" onclick="menuNav('menu1');"><span style="padding-left: 5px; font-weight: bold;">Administrér</span></div>
<div id="menu2" class="divmenuhead close menuframe" onclick="menuNav('menu2');"><span style="padding-left: 5px; font-weight: bold;">Links</span>
<div class="divmenutopcat" onclick="location.href='/newmainarea.asp'" onmouseover="this.className='divmenutopcatover';" onmouseout="this.className='divmenutopcatout';"><span style="padding-left: 8px;">Link1</span></div>
<div class="divmenutopcat" onclick="location.href='/newtopcat.asp'" onmouseover="this.className='divmenutopcatover';" onmouseout="this.className='divmenutopcatout';"><span style="padding-left: 8px;">Link2</span></div>
</div>
<div id="menu2c" class="divmenuhead open menuframe" onclick="menuNav('menu2');"><span style="padding-left: 5px; font-weight: bold;">Links</span></div>
<div id="menu3" class="divmenuhead close menuframe" onclick="menuNav('menu3');"><span style="padding-left: 5px; font-weight: bold;">Info</span>
<div class="divmenutopcat" onclick="location.href='/newmainarea.asp'" onmouseover="this.className='divmenutopcatover';" onmouseout="this.className='divmenutopcatout';"><span style="padding-left: 8px;">Emne1</span></div>
<div class="divmenutopcat" onclick="location.href='/newtopcat.asp'" onmouseover="this.className='divmenutopcatover';" onmouseout="this.className='divmenutopcatout';"><span style="padding-left: 8px;">Emne2</span></div>
<div class="divmenutopcat" onclick="location.href='/newsubcat.asp'" onmouseover="this.className='divmenutopcatover';" onmouseout="this.className='divmenutopcatout';"><span style="padding-left: 8px;">Emne3</span></div>
<div class="divmenutopcat" onclick="location.href='/newsubcat.asp'" onmouseover="this.className='divmenutopcatover';" onmouseout="this.className='divmenutopcatout';"><span style="padding-left: 8px;">Emne4</span></div>
</div>
<div id="menu3c" class="divmenuhead open menuframe" onclick="menuNav('menu3');"><span style="padding-left: 5px; font-weight: bold;">Info</span></div>
</form>
</body>
</html>
Håber vi er ved at komme derhen af. ;)
- Snap