470,636 Members | 1,543 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

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

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='n one';
if (is_open == 'none') {
document.getElementById(objeto).style.display='blo ck';
}
else {
document.getElementById(objeto).style.display='non e' ;
}
}
..
..
..
<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>
..
..
Dec 8 '06 #1
4 2039
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.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 8 '06 #2
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>
Dec 8 '06 #3
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 8 '06 #4
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.o ptions[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.di splay='none';
// Si no estaba expandido, que lo expanda.
if (esta_abierto == 'none') {
document.getElementById(objeto).style.display='blo ck';
alert("Estaba cerrado");
}
else {
document.getElementById(objeto).style.display='non e' ;
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:ol************@yahoo.es">ol********** **@yahoo.es</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/>
Dec 8 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by bearclaws | last post: by
1 post views Thread by Randall Sell | last post: by
5 posts views Thread by toylet | last post: by
2 posts views Thread by Shahid | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.