Foros del Web » Programando para Internet » Javascript »

menu desplegable

Estas en el tema de menu desplegable en el foro de Javascript en Foros del Web. hola todos, primero que nada felices fiestas para todos. Ahora una consulta, necesito hacer un menu desplegable con javascript, donde puedo encontrar? tengo uno pero ...
  #1 (permalink)  
Antiguo 27/12/2005, 05:40
 
Fecha de Ingreso: marzo-2005
Mensajes: 90
Antigüedad: 19 años, 1 mes
Puntos: 0
menu desplegable

hola todos, primero que nada felices fiestas para todos. Ahora una consulta, necesito hacer un menu desplegable con javascript, donde puedo encontrar? tengo uno pero solo me funciona para asp, y no para php, y tb solo me funciona en IE y no en FireFox. lo adjunto para que lo vean
Desde ya muchas gracias.


menu:
/* parametri */
jjm_chiusuraInt=1000;
jjm_chiusuraVoceInt=300;

if (typeof(jjm_home)=="undefined") jjm_home = false;
jjm_selectPaeseId = "paesi";
jjm_selectProdottoId = jjm_home? "siteFindProduct:DdlSelectCategory": "siteHeader:siteFindProduct:DdlSelectCategory" ;
/**/

document.write("<div id=\"menu\" style=\"LEFT: 300px; POSITION: absolute; TOP: 33px\"></div>");

onLoad="";
window.onload = new Function("eval(onLoad)");

jjm_timerID="";
jjm_id = new Array;

onLoad += "jjm_inizializza();";

function jjm_inizializza()
{
if (jjm_home)
{
selectPaeseWidth = 100;
//document.getElementById(jjm_selectPaeseId).style.w idth = 100;
document.getElementById(jjm_selectPaeseId).style.w idth = selectPaeseWidth;
}
selectProdottoWidth = 200;
//document.getElementById(jjm_selectProdottoId).styl e.width = 200;
document.getElementById(jjm_selectProdottoId).styl e.width = selectProdottoWidth;

linkProdotti.onmouseover = new Function ("document.prodotti.src='images/btn_productos_over.gif';jjm_apri('v1');");
linkProdotti.onmouseout = new Function ("document.prodotti.src='images/btn_productos.gif';jjm_chiudi('v1');");
linkServizi.onmouseover = new Function ("document.servizi.src='images/btn_servicio_over.gif';jjm_apri('v2');");
linkServizi.onmouseout = new Function ("document.servizi.src='images/btn_servicio.gif';jjm_chiudi('v2');");
linkAzienda.onmouseover = new Function ("document.azienda.src='images/btn_empresa_over.gif';jjm_apri('v3');");
linkAzienda.onmouseout = new Function ("document.azienda.src='images/btn_empresa.gif';jjm_chiudi('v3');");
}

function jjm_apri(id)
{
if (jjm_timerID!="") clearTimeout(jjm_timerID);
if (jjm_id[jjm_id.length-1] != id)
{
if (jjm_home && document.getElementById(jjm_selectPaeseId).style.w idth != selectPaeseWidth) document.getElementById(jjm_selectPaeseId).style.w idth = selectPaeseWidth;
if (document.getElementById(jjm_selectProdottoId).sty le.width != selectProdottoWidth) document.getElementById(jjm_selectProdottoId).styl e.width = selectProdottoWidth;

jjm_id = jjm_gerarchiaLeggi(id);
var menuMatrice = new Array();
var menuMatriceLength = 0;
for (var i=0; i<jjm_id.length; i++)
{
menuMatrice[i] = new Array();
var sottoVoci = jjm_SottoVociLeggi(jjm_id[i]);
for (var j=0; j<sottoVoci.length; j++) menuMatrice[i][j] = sottoVoci[j];
menuMatriceLength += sottoVoci.length;
}
var delta = new Array();
delta[0] = 0;

menu.style.left = 300+parseInt(jjm_parXML.getElementsByTagName(jjm_i d[0])[0].getAttribute('x'));

var str = "<table cellspacing=0 cellpadding=0 border=0>";
for (var j=0; j<20 && menuMatriceLength>0; j++) // # max righe menu
{
str += "<tr>";
for (var i=0; i<menuMatrice.length; i++)
{
if (delta==null || j<delta[i] || menuMatrice[i][j-delta[i]]==null) str += "<td></td>";
else
{
var idCurr = menuMatrice[i][j-delta[i]].nodeName;
var voce = menuMatrice[i][j-delta[i]].getAttribute('n');
var classe = "jjm_menu";
if (idCurr==jjm_id[i+1])
{
delta[i+1] = j;
classe += "Sel";
}
str += "<td onmouseover=\"jjm_apri('"+ idCurr +"')\" onmouseout=\"jjm_chiudi()\" class=\""+ classe +"\"";
var link = unescape(menuMatrice[i][j-delta[i]].getAttribute('l'));
var esterna = menuMatrice[i][j-delta[i]].getAttribute('est');
if (link=="") str += ">"+ voce +"</td>";
else str += " onclick=\""+ (esterna? "": "location='"+ link +"'") +"\" style=\"cursor:hand;\"><a href=\""+ link +"\""+ (esterna? " target=\"_blank\"": "") +">"+ voce +"</a></td>";
menuMatriceLength--;

if (jjm_home)
{
if (j==0)
{
if (i==2) document.getElementById(jjm_selectPaeseId).style.w idth = "0";
else if (i==1 && parseInt(menu.style.left)>300) document.getElementById(jjm_selectPaeseId).style.w idth = 66;
}
else if (j==9 && i==1) document.getElementById(jjm_selectProdottoId).styl e.width = 136;
}
else if ((j==1 || j==2) && i>0 || parseInt(menu.style.left)>450) document.getElementById(jjm_selectProdottoId).styl e.width = 0;
}
}
str += "</tr>";
}
str += "</table>";
menu.innerHTML = str;
}
}

function jjm_chiudi2()
{
if (jjm_id.length<=1)
{
menu.innerHTML = "";
jjm_id = new Array();

if (jjm_home && document.getElementById(jjm_selectPaeseId).style.w idth != selectPaeseWidth) document.getElementById(jjm_selectPaeseId).style.w idth = selectPaeseWidth;
if (document.getElementById(jjm_selectProdottoId).sty le.width != selectProdottoWidth) document.getElementById(jjm_selectProdottoId).styl e.width = selectProdottoWidth;
}
else
{
jjm_apri(jjm_id[jjm_id.length-2]);
jjm_timerID = window.setTimeout("jjm_chiudi2()", jjm_chiusuraVoceInt);
}
}

function jjm_chiudi()
{
if (jjm_timerID!="") clearTimeout(jjm_timerID);
jjm_timerID = window.setTimeout("jjm_chiudi2()", jjm_chiusuraInt);
}

function jjm_carica()
{
jjm_parXML = jjm_par.XMLDocument;
}

function jjm_gerarchiaLeggi(id)
{
var gerarchia = new Array();
var i = 0;
gerarchia[0] = id;
while (jjm_parXML.getElementsByTagName(gerarchia[i])[0].parentNode.nodeName != "dati")
{
gerarchia[i+1] = jjm_parXML.getElementsByTagName(gerarchia[i])[0].parentNode.nodeName;
i++;
}
return gerarchia.reverse();
}
function jjm_SottoVociLeggi(id)
{
return jjm_parXML.getElementsByTagName(id)[0].childNodes;
}

onLoad += "jjm_carica();";
  #2 (permalink)  
Antiguo 27/12/2005, 05:58
Avatar de JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 2 meses
Puntos: 772
Hola Facha

En esta página, en la sección Generador puedes crearte un menú desplegable de forma muy sencilla:

http://www.tunait.com/javascript/

Saludos,
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:18.