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: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Thursday February 8 2018 - 06:02:38

Hiding menu on certain pages


Poster: jimnutt
Dated: Thursday September 26 2002 - 1:19:13 BST

Looking for information on how I might hide the menu on certain pages. Because I am using include files I can't use logic to decide if I should include the _array.js file. What would be ideal is a function similar to placemenu() which I am using with good results. Not using placemenu just results in the menu showing up at the top of the page.
I notice a closeallmenus() function in the mmenu.js file but it isn't doing what I would expect.


Poster: kevin3442
Dated: Tuesday October 15 2002 - 22:51:27 BST

Hi,

Have you tried the popdn() function? According to other posts I've read, popdn() should hide the menu. Since you can't use conditionals, I guess you'd have to call popdn() with onLoad. The only problem I might anticipate is, would the menu have to be displayed on the page briefly before popdn() is called? I haven't tried this, so I have no idea. This shouldn't be bad visually when going from a page where the menu is displayed to a page where it isn't; it would probably appear as though the menu was "left over" briefly from the previous page, then disappeared as part of the normal loading process for the current page. However, going from a page where the menu isn't displayed to another page where it isn't displayed might cause a "flash" effect, where the menu appears briefly then disappears; not a great result (you could probably solve this by putting your menu in a frame). Maybe worth a try... I'd be curious to know the results if you do try it.

Good Luck,

Kevin


Poster: Andy
Dated: Tuesday October 15 2002 - 22:57:05 BST

popdn() will only work on menus that are not set "Always Visible"

What you could do is this

Code: Select all

menuObj = getMenuByName("mainmenu")
SDiv("menu"+menuObj,0)

This will hide the menu, and this:

Code: Select all

menuObj = getMenuByName("mainmenu")
SDiv("menu"+menuObj,1)

Should bring it back again

Cheers
Andy

Hiding menu on certain pages


Poster: jimnutt
Dated: Wednesday October 30 2002 - 16:52:27 GMT

Thanks for the help on this, here's what I did.
Added two functions at the bottom of mmenu.js, I'd would have liked not to edit this file but placing the code anywhere else caused the menu to flicker on and then off.
Immediately after the functions I turned off the menu so it is off by default

Code: Select all

// Custom so the menu is off by default
function menuoff(menu){
   menuObj = getMenuByName(menu);
   SDiv("menu"+menuObj,0);
   }
function menuon(menu){
   menuObj = getMenuByName(menu);
   SDiv("menu"+menuObj,1);
   }
menuoff("simplemenu1");

Then where I need the menu I just call the menuon() function immediately following the placemenu() call.

Code: Select all

<script>
PlaceMenu("simplemenu1");
menuon("simplemenu1");
</script>

Everything looks, good, thanks again for the help

Try this


Poster: tgaql
Dated: Wednesday October 30 2002 - 20:36:42 GMT

I think it's fine to add conditional logic, because I put it in the INCLUDED _array.js file, like below (see mapping-your-future.org for an example).


// put this below the menu style code
var lowerCaseHref = window.document.location.href.toLowerCase();

// if one of the below directories is part of the URL, then display the corresponding menu
if ((lowerCaseHref.indexOf("/planning")>0) || (lowerCaseHref.indexOf("/services/fao")>0)){

// BEGIN MAIN MENU
// This is the array that contains your mainmenu properties and details
addmenu(menu=[ ect...

// otherwise
} else if ((lowerCaseHref.indexOf("/features/dmtensteps.htm")>0) || (lowerCaseHref.indexOf("/paying/default.htm")>0)) {

// BEGIN 2nd MENU
// This is the array that contains your mainmenu properties and details
addmenu(menu=[ ect...

}

etc... and our menu is much more complicated, but I didn't have to modify the mmenu.js file, and I put all the logic in the one _array.js file. Therefore, we only have to maintain one file for all the Milonic menus across our fairly large site. The above code is only pseudo-code, so I'm not sure that it works like written above, but you get the idea. The code seems to work great in NN 4+ and IE 5+ for sure, but it should work across most other browsers, too. Let me know if you see a problem with the code, of if you know of a cleaner way to create the same code (I'm no JavaScript expert)

Aaron