Hiding a menu

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
Jay Shobe
Beginner
Beginner
Posts: 3
Joined: Mon Nov 29, 2004 11:45 pm

Hiding a menu

Post by Jay Shobe »

I'm using some code I found on this forum to show/hide a menu. It works great, but the problem is when I resize the browser window, the menu re-appears. Here's the code. I'm just using a standard sample menu_data.js.

Code: Select all

<html>
<body>
		
<script type="text/javascript" src="milonic_src.js"></script>	
<script type="text/javascript" src="mmenudom.js"></script>	
<script type="text/javascript" src="menu_data.js"></script>	
<script	type="text/javascript">

function mm_showMenu(menuName) // , alwaysVisState = optional. 1=on, 0=off 
{ 
  if (arguments.length > 1) _m[getMenuByName(menuName)][7] = arguments[1]; 
  popup(menuName); 
} 

function mm_hideMenu(menuName) // , alwaysVisState = optional. 1=on, 0=off 
{ 
  var menuNum = getMenuByName(menuName); 
  if (arguments.length > 1) { 
    _m[menuNum][7] = arguments[1]; 
  } 
  menuDisplay(menuNum, 0); 
} 

function ShowHide(show) {
debugger
if (show) {mm_showMenu("Main Menu")}
else {mm_hideMenu("Main Menu")}

}

</script>
<button onclick="ShowHide(true)" style="position:absolute;top:300px">Show</button>
<button onclick="ShowHide(false)" style="position:absolute;top:350px">Hide</button>
</body>
</html>
Thanks,

Jay
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

The reason it shows after the browser is 'resized' is because you are in effect reloading the page and therefore start at the beginning again. I think the only thing you could do would be to add to the function telling it to keep whatever state it has when the page is reloaded, but I don't know if that would interfere with what happens to the menu when you go to another page.

Ruth
Jay Shobe
Beginner
Beginner
Posts: 3
Joined: Mon Nov 29, 2004 11:45 pm

Post by Jay Shobe »

Thanks for the input, Ruth.

I set the initial value of the alwaysvisible property to false, and it seems to work properly.

Jay
User avatar
rudy
Mega User
Mega User
Posts: 161
Joined: Thu Jan 15, 2004 11:39 pm
Location: Scottsdale, Arizona
Contact:

Re: Hiding a menu

Post by rudy »

Nice code work - do you have a URL for us to see it in action?
Jay Shobe wrote:I'm using some code I found on this forum to show/hide a menu. It works great, but the problem is when I resize the browser window, the menu re-appears. Here's the code. I'm just using a standard sample menu_data.js.

Code: Select all

<html>
<body>
		
<script type="text/javascript" src="milonic_src.js"></script>	
<script type="text/javascript" src="mmenudom.js"></script>	
<script type="text/javascript" src="menu_data.js"></script>	
<script	type="text/javascript">

function mm_showMenu(menuName) // , alwaysVisState = optional. 1=on, 0=off 
{ 
  if (arguments.length > 1) _m[getMenuByName(menuName)][7] = arguments[1]; 
  popup(menuName); 
} 

function mm_hideMenu(menuName) // , alwaysVisState = optional. 1=on, 0=off 
{ 
  var menuNum = getMenuByName(menuName); 
  if (arguments.length > 1) { 
    _m[menuNum][7] = arguments[1]; 
  } 
  menuDisplay(menuNum, 0); 
} 

function ShowHide(show) {
debugger
if (show) {mm_showMenu("Main Menu")}
else {mm_hideMenu("Main Menu")}

}

</script>
<button onclick="ShowHide(true)" style="position:absolute;top:300px">Show</button>
<button onclick="ShowHide(false)" style="position:absolute;top:350px">Hide</button>
</body>
</html>
Thanks,

Jay
Rudy
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi Jay,

I'm with Rudy, I like that. I just tested it. Now, the only thing I'd like to get it to do is, have only one button that had the correct text depending on the 'condition' of the menu, hidden or visible and then make it scroll down as you scroll down the page :) Oh, and I guess the menu would have to open at whatever place on the page to which one had scrolled or it would have to take you back to the top when you clicked on the 'show menu' .... :)


Ruth
Post Reply