+ + JavaScript

08/12/2006 - 19:40 por Winston | Informe spam
Esto es un pedazo de codigo del archivo menu html.
Quiero hacer un menu desplegable (en cada sub UL), BIEN SENCILLO.
Al final adjunto la funcion.


<script src="fun_menu.js"></script>
<form name="Reloj"><input class="relojes" type="text" name="aqui_hora"
size="12" onfocus="window.document.Reloj.aqui_hora.blur()"></form>
<hr/>
<ul>
<li><a href="index.shtml" title="Objetivo">Introduccion</a>
<li><a href="cv.shtml" title="Texto + Listas -
(C.V.)">C.V</a></li>
<li><a href="multimedia.shtml"
title="Multimedia">Multimedia</a></li>
<li><a href="dondeestuve.shtml" title="Enlaces">Enlaces</a>
<li id="cabcontenido">
<a id="contenido" href="preguntas.shtml"
onclick="MostrarMenu('contenido')" title="Preguntas">Preguntas</a>
<ul id="divcontenido" style="display='none'">
<li><a href="preg_html.shtml" title="Preguntas sobre
HTML">HTML</a></li>
<li><a href="preg_css.shtml" title="Preguntas sobre
CSS">CSS</a></li>
<li><a href="preg_javascript.shtml" title="Preguntas sobre
JavaScript">JavaScript</a></li>
<li><a href="preg_php.shtml" title="Preguntas sobre
PHP">PHP</a></li>
</ul>

.
.
.
.
.

No entiendo porque el autor de esta funcion que adjunto, necesita de las
imagenes. Yo lo quiero hacer simplemente con texto.



function MostrarMenu(objeto) {
rutaimg = new String(document.getElementById(objeto).src);
ruta = rutaimg.substr(0, rutaimg.length - 9) ;
img = rutaimg.substr(rutaimg.length - 9, 9) ;
//oculto todas las capas y asigno posicion original a la imagen
document.getElementById("contenido").src = ruta+"abajo.gif" ;
document.getElementById("divcontenido").style.display='none' ;
document.getElementById("actualidad").src = ruta+"abajo.gif" ;
document.getElementById("divactualidad").style.display='none' ;
document.getElementById("buscador").src = ruta+"abajo.gif" ;
document.getElementById("divbuscador").style.display='none' ;
//segun imagen muestro la capa del parametro
if( img == "abajo.gif" ) {
document.getElementById(objeto).src = ruta+"derec.gif" ;
document.getElementById("div"+objeto).style.display='block' ;
}
else {
document.getElementById(objeto).src = ruta+"abajo.gif" ;
document.getElementById("div"+objeto).style.display='none' ;
}
 

Leer las respuestas

#1 zz
08/12/2006 - 19:59 | Informe spam
imagino que el menu muestra los tipicos iconos junto a las opciones del
menu, es solo cuestion de diseño, para resaltar mas aun, hacer mas llamativo
el menu, siempre es bueno agregar una interfaz agradable a los menus,
sobretodo en aquellos items del menu que consideras de mas relevancia.

ademas parece que en la funcion las flecha "abajo.gif" indica que el menu se
encuentra desplegado

algo asi
__________________________
|Menu 1 > |[colapsado]
|-- |
| Menu 2 \/ |[desplegado]
| opcion1 del menu 2 |
| opcion 2 del menu 2 |
|_________________________ |


Saluts.
Espero que te sirva.

zz [MX]
cuasi-musico,semi-poeta y loco

"Winston" wrote in message
news:elcbik$903$
Esto es un pedazo de codigo del archivo menu html.
Quiero hacer un menu desplegable (en cada sub UL), BIEN SENCILLO.
Al final adjunto la funcion.


<script src="fun_menu.js"></script>
<form name="Reloj"><input class="relojes" type="text" name="aqui_hora"
size="12" onfocus="window.document.Reloj.aqui_hora.blur()"></form>
<hr/>
<ul>
<li><a href="index.shtml" title="Objetivo">Introduccion</a>
<li><a href="cv.shtml" title="Texto + Listas -
(C.V.)">C.V</a></li>
<li><a href="multimedia.shtml" title="Multimedia">Multimedia</a></li>
<li><a href="dondeestuve.shtml" title="Enlaces">Enlaces</a>
<li id="cabcontenido">
<a id="contenido" href="preguntas.shtml"
onclick="MostrarMenu('contenido')" title="Preguntas">Preguntas</a>
<ul id="divcontenido" style="display='none'">
<li><a href="preg_html.shtml" title="Preguntas sobre
HTML">HTML</a></li>
<li><a href="preg_css.shtml" title="Preguntas sobre
CSS">CSS</a></li>
<li><a href="preg_javascript.shtml" title="Preguntas sobre
JavaScript">JavaScript</a></li>
<li><a href="preg_php.shtml" title="Preguntas sobre
PHP">PHP</a></li>
</ul>

.
.
.
.
.

No entiendo porque el autor de esta funcion que adjunto, necesita de las
imagenes. Yo lo quiero hacer simplemente con texto.



function MostrarMenu(objeto) {
rutaimg = new String(document.getElementById(objeto).src);
ruta = rutaimg.substr(0, rutaimg.length - 9) ;
img = rutaimg.substr(rutaimg.length - 9, 9) ;
//oculto todas las capas y asigno posicion original a la imagen
document.getElementById("contenido").src = ruta+"abajo.gif" ;
document.getElementById("divcontenido").style.display='none' ;
document.getElementById("actualidad").src = ruta+"abajo.gif" ;
document.getElementById("divactualidad").style.display='none' ;
document.getElementById("buscador").src = ruta+"abajo.gif" ;
document.getElementById("divbuscador").style.display='none' ;
//segun imagen muestro la capa del parametro
if( img == "abajo.gif" ) {
document.getElementById(objeto).src = ruta+"derec.gif" ;
document.getElementById("div"+objeto).style.display='block' ;
}
else {
document.getElementById(objeto).src = ruta+"abajo.gif" ;
document.getElementById("div"+objeto).style.display='none' ;
}

Preguntas similares