Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:55

How does closeAllMenu() work?


Poster: Jukka
Dated: Friday September 15 2006 - 10:52:02 BST

I have about 20 menus in one jsp-page, but only few of them are visible at a time. Depending on a situation different menus should be displayed.

http://www.milonic.com/menu_methods.php says:

"menuDisplay displays a menu. You need to have a reference to a menu or other HTML object and show/hide is boolean value:
Syntax is menuDisplay(gmobj("menuname"),1) to show and menuDisplay(gmobj("menuname"),0) to hide."

"closeAllMenus will hide ALL menus, even if they are visible but moved out of view. This command is used to clear the screen of unwanted menus."


I made a test:
menu_data.js
Code:
...
with(milonic=new menuname("menuname"))
{
    position="relative"; alwaysvisible=0; orientation="horizontal"; style=menuStyle;
    aI("text=menuitem0;url=#;");
    aI("text=menuitem1;url=#;");
    aI("text=menuitem2;url=#;");
}
drawMenus();

testmenu.html
Code:
...
<a href="#" onclick="javascript:menuDisplay(gmobj("menuname"),1)">Close all menus</a>
<a href="#" onclick="javascript:closeAllMenus();">Close all menus</a>
...

...but the menu only stays hidden.
If I change the property alwaysvisible to 1, I can't hide the menu with the method closeAllMenus(),
and if it is null or 0 the menu is hidden and I can't get it visible with method menuDisplay.

What should I do?


Poster: kevin3442
Dated: Monday September 25 2006 - 9:39:48 BST

Hi Jukka,

You have a couple of syntax issues in your sample code. For example, the double quotes around "menuname" here:
Code:
<a href="#" onclick="javascript:menuDisplay(gmobj("menuname"),1)">Close all menus</a>

will will cause a parsing error for the onclick attribute (i.e., onclick="..."). Single quotes would be better.

Also, you don't need to follow onclick with "javascript". I.e.,
Code:
onclick="closeAllMenus()"

will work.

closeAllMenus() will close all open menus that are not set to alwaysvisible=1; i.e., alwaysvisible takes precedence.

Some have found the menuDisplay() function a little tricky. An easier one is popup(). You might five that a try. Try this:
Code:
<a href="#" onclick="popup('menuname', 1)">Open 'menuname'</a>
<a href="#" onclick="closeAllMenus();">Close all menus</a>


If you need to use menuDisplay() for something that popup() and closeAllMenus() can't handle, give a holler and we'll work it out.

Hope that helps,

Kevin