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:02
Hiding a menu
Poster: Jay Shobe
Dated: Wednesday December 1 2004 - 16:39:35 GMT
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:
<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>
<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
Poster: Ruth
Dated: Wednesday December 1 2004 - 17:56:00 GMT
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
Poster: Jay Shobe
Dated: Wednesday December 1 2004 - 18:34:02 GMT
Thanks for the input, Ruth.
I set the initial value of the alwaysvisible property to false, and it seems to work properly.
Jay
Re: Hiding a menu
Poster: rudy
Dated: Thursday December 2 2004 - 21:40:32 GMT
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.
Thanks,
Jay
Code:
<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>
<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
Poster: Ruth
Dated: Friday December 3 2004 - 3:17:16 GMT
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