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.
Hiding menu on certain pages
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
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
popdn() will only work on menus that are not set "Always Visible"
What you could do is this
This will hide the menu, and this:
Should bring it back again
Cheers
Andy
What you could do is this
Code: Select all
menuObj = getMenuByName("mainmenu")
SDiv("menu"+menuObj,0)
Code: Select all
menuObj = getMenuByName("mainmenu")
SDiv("menu"+menuObj,1)
Cheers
Andy
Hiding menu on certain pages
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
Then where I need the menu I just call the menuon() function immediately following the placemenu() call.
Everything looks, good, thanks again for the help
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");
Code: Select all
<script>
PlaceMenu("simplemenu1");
menuon("simplemenu1");
</script>
Try this
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
// 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