Where is the mistake? <UL> + style.display

W

Winston

Where is the mistake?

I want to make a simple menu. These are two pieces of two files...

function ShowMenu(objeto) {
is_open = document.getElementById(objeto).style.display;
document.getElementById("menu_p").style.display='none';
if (is_open == 'none') {
document.getElementById(objeto).style.display='block';
}
else {
document.getElementById(objeto).style.display='none' ;
}
}


..
..
..
<li><a href="preguntas.shtml" onclick="ShowMenu('menu_p')"
title="P">Preguntas</a></li>
<ul id="menu_p" style="display='none'">
<li><a href="preg_html.shtml">HTML</a></li>
<li><a href="preg_css.shtml"">CSS</a></li>
<li><a href="preg_javascript.shtml">JavaScript</a></li>
<li><a href="preg_php.shtml">PHP</a></li>
</ul>
<li>
..
..
 
E

Evertjan.

Winston wrote on 08 dec 2006 in comp.lang.javascript:
<li><a href="preguntas.shtml" onclick="ShowMenu('menu_p')"
title="P">Preguntas</a></li>

the href is executed leaving the page for another or the same one,
and the script result cannot be seen anymore.

try:

<a href="preguntas.shtml" onclick="ShowMenu('menu_p');return false;"
title="P">Preguntas</a>

href="preguntas.shtml" is here only executed if js is off or not available.
 
W

Winston

Evertjan. escribió:
Winston wrote on 08 dec 2006 in comp.lang.javascript:


the href is executed leaving the page for another or the same one,
and the script result cannot be seen anymore.

try:

<a href="preguntas.shtml" onclick="ShowMenu('menu_p');return false;"
title="P">Preguntas</a>

href="preguntas.shtml" is here only executed if js is off or not available.

When I click on [preguntas.shtml] the page load normally in other DIV.
That is OK, but my problem is that when I click on it I have, just for
ONE second the submenu.
<li><a href="preg_html.shtml">HTML</a></li>
<li><a href="preg_css.shtml">CSS</a></li>
 
E

Evertjan.

Winston wrote on 08 dec 2006 in comp.lang.javascript:
Evertjan. escribió:
Winston wrote on 08 dec 2006 in comp.lang.javascript:


the href is executed leaving the page for another or the same one,
and the script result cannot be seen anymore.

try:

<a href="preguntas.shtml" onclick="ShowMenu('menu_p');return false;"
title="P">Preguntas</a>

href="preguntas.shtml" is here only executed if js is off or not
available.

When I click on [preguntas.shtml] the page load normally in other DIV.
That is OK, but my problem is that when I click on it I have, just for
ONE second the submenu.
<li><a href="preg_html.shtml">HTML</a></li>
<li><a href="preg_css.shtml">CSS</a></li>

That is as it should be, given your code.
 
W

Winston

Evertjan. escribió:
Winston wrote on 08 dec 2006 in comp.lang.javascript:
Evertjan. escribió:
Winston wrote on 08 dec 2006 in comp.lang.javascript:

<li><a href="preguntas.shtml" onclick="ShowMenu('menu_p')"
title="P">Preguntas</a></li>
the href is executed leaving the page for another or the same one,
and the script result cannot be seen anymore.

try:

<a href="preguntas.shtml" onclick="ShowMenu('menu_p');return false;"
title="P">Preguntas</a>

href="preguntas.shtml" is here only executed if js is off or not
available.
When I click on [preguntas.shtml] the page load normally in other DIV.
That is OK, but my problem is that when I click on it I have, just for
ONE second the submenu.
<li><a href="preg_html.shtml">HTML</a></li>
<li><a href="preg_css.shtml">CSS</a></li>

That is as it should be, given your code.

[fun_menu.js]

function Cambiar() {
var posibles = document.cambiando_estilos.Seleccionar;

document.getElementById("estilos").href=posibles.options[posibles.selectedIndex].value;
}


function Reloj_Activo(){
Hora_Actual = new Date();
hora = Hora_Actual.getHours();
minuto = Hora_Actual.getMinutes();
segundo = Hora_Actual.getSeconds();
salida = hora + " : " + minuto + " : " + segundo;
document.Reloj.aqui_hora.value = salida;
setTimeout("Reloj_Activo()",1000);
}

function MostrarMenu(objeto) {
esta_abierto = document.getElementById(objeto).style.display;
//document.getElementById("menu_preguntas").style.display='none';
// Si no estaba expandido, que lo expanda.
if (esta_abierto == 'none') {
document.getElementById(objeto).style.display='block';
alert("Estaba cerrado");
}
else {
document.getElementById(objeto).style.display='none' ;
alert("Estaba abierto");
}
}


[menu.html]

<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>
<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><a href="preguntas.shtml"
onclick="MostrarMenu('menu_preguntas')" title="Preguntas">Preguntas</a></li>
<div id="menu_preguntas" style="display='block'">
<ul>
<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>
</div>
<li><a href="horarios.shtml" title="Horario de clase">Horario</a>
<ul>
<li><a href="horario1.shtml" title="Horario (Tablas)">Horario
(Tablas)</a></li>
<li><a href="horario2.shtml" title="Horario (Capas)">Horario
(Capas)</a></li>
</ul>

<li><a href="formularios.shtml" title="Formulario">Formularios</a>
<ul>
<li><a href="form_salida.shtml" title="Formulario -
Submit">Formularios (Haciendo el Submit)</a></li>
</ul>

<li><a href="imagen_0.shtml" title="Imagenes Inmenzas">Imagenes
Inmenzas</a>
<ul>
<li><a href="imagen_1.shtml" title="Imagenes
Inmenzas">Partiendo en una tabla</a></li>
<li><a href="imagen_2.shtml" title="Imagenes
Inmenzas">Con Celsspading=0</a></li>
<li><a href="imagen_3.shtml" title="Imagenes
Inmenzas">Con Border=0</a></li>
</ul>
<li><a href="javascript.shtml" title="JavaScript">Javascript</a>
<ul>
<li><a href="j_tabla.shtml" title="Tabla de Multiplicar
y mas...">Tabla de Multiplicar</a></li>
</ul>

</ul>
<hr/>
<center> <a
href="mailto:eek:[email protected]">[email protected]</a> </center>
<hr/>
<form name="cambiando_estilos">
¿Cambiar a <select name="Seleccionar" onchange="Cambiar()">
<option value="estilo1.css"> Estilo 1?
</option>

<option selected value="estilo2.css"> Estilo 2? </option>
<option value="estilo3.css"> Estilo 3? </option>
</select>
</form>
<hr/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top