Estoy por armar un sitio web donde el menu es incluido con "include". El problema es que el menu javascript es desplegable, entonces cuando despliego un submenu e ingreso en otra seccion, vuelve a cargar el menu pero sin dejarlo desplegado. como puedo hacer para que me quede desplegada la seccion?
No hay alguna posibilidad de que cuando pongo el include en cada pagina tambien agrege una sentencia que indique que en esta pagina determinado boton quede desplegado?
-----------------------------------------------------------------------
aqui les dejo el codigo del index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="791" border="0">
<tr>
<td width="351" height="537" align="left" valign="top"><?php
include("menu.htm");
?></td>
<td width="430" bgcolor="#CCCCCC"> </td>
</tr>
</table>
<p> </p>
</body>
</html>
-----------------------------------------------------------------------
Este es el codigo del menu que se incluye en todas las paginas:
<script type="text/javascript">
/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only
if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}
function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsBy TagName("span"); //DynamicDrive.com change
if(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";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(off set, end))
}
}
return returnvalue;
}
function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display ="block"
}
}
function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display= ="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}
if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction
if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate
</script>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top"><table width="2" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="63" colspan="3" align="center" valign="top"> </td>
</tr>
<tr>
<td width="6"> </td>
<td width="198" align="left" valign="top"><!-- Keep all menus within masterdiv-->
<div id="masterdiv"> <br>
<br>
<div class="menutitle"><br>
</div>
<div class="menutitle" onClick="SwitchMenu('sub1')"><a href="publi_01.html" target="visor">seccion 1 </a><br>
</div>
<div class="menutitle" onClick="SwitchMenu('sub1')"><a href="publi_02.html" target="visor">seccion 2 </a><br>
</div>
<div class="menutitle" onClick="SwitchMenu('sub1')"><a href="publi_03.html" target="visor">seccion 3</a></div>
<div class="menutitle" onClick="SwitchMenu('sub1')"><a href="publi_04.html" target="visor">seccion 4</a></div>
<div class="menutitle" onClick="SwitchMenu('sub2')"><a href="publi_05.html" target="visor">seccion 5</a></div>
<div class="menutitle" onClick="SwitchMenu('sub3')">seccion 6</div>
<span class="submenu" id="sub3">· <a href="seccion6-1.php" target="visor">Nro. 1 </a><br>
· Nro. 2 <br>
· Nro. 3 <br>
· Nro. 4 <br>
· Nro. 5 <br>
· Nro. 6 <br>
<br>
</span>
<div class="menutitle" onClick="SwitchMenu('sub6')">seccion 7</div>
<span class="submenu" id="sub6">
· <a href="prisma_01.html" target="visor">Nro. 1 </a><br>
· Nro. 2<br>
· <a href="prisma_03.html" target="visor"> Nro. 3<br>
· <a href="prisma_04.html" target="visor"> Nro. 4<br>
· <a href="prisma_05.html" target="visor"> Nro. 5<br>
· <a href="prisma_06.html" target="visor"> Nro. 6
<br>
<br>
</span>
<div class="menutitle"></div>
</div> </td>
<td width="664" align="right" valign="top"> </td>
</tr>
</table>