Where I should call this function?

A

Asarus

Where I should call this function?
If I call it in href doesn't work. (I want to make a simple menu)

function MostrarMenu(objeto) {
esta_abierto = document.getElementById(objeto).style.display;
document.getElementById("menu_preguntas").style.display='none';
if (esta_abierto == 'none') {
document.getElementById(objeto).style.display='none';
alert("Estaba cerrado");
}
else {
document.getElementById(objeto).style.display='none' ;

alert("Estaba abierto");
}
}

<li><a href="preguntas.shtml"
nclick="MostrarMenu('menu_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>
 
E

Evertjan.

Asarus wrote on 14 dec 2006 in comp.lang.javascript:
if (esta_abierto == 'none') {
document.getElementById(objeto).style.display='none';
alert("Estaba cerrado");
}
else {
document.getElementById(objeto).style.display='none' ;

document.getElementById(objeto).style.display='' ;
 

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,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top