ras
Junior Member
Posts: 2
Registered: 11/26/2003
Member Is Offline
|
| posted on 11/26/2003 at 02:47 PM |
|
|
Load menu from onClick event
I'd like to be able to launch a menu from OnClick event associated with an image in an anchor. Is this possible?
|
|
|
ras
Junior Member
Posts: 2
Registered: 11/26/2003
Member Is Offline
|
| posted on 11/26/2003 at 02:51 PM |
|
|
Or make the menu invisible until I need it...
|
|
|
BigJ
Newbie
Posts: 1
Registered: 2/13/2004
Member Is Offline
|
| posted on 2/13/2004 at 07:12 PM |
|
|
add the following two functions to the menu.js file:
// --------------------------------------------------------------------------------
function show_menu(menu_id){
// hide the menu if it is visible
if(A_MENUS[menu_id].a_children[0].e_oelement.style.visibility == 'visible'){
hide_menu(menu_id);
return;
}
// hide any other elements
for (var i = 0; i < A_MENUS.length; i++){
if(i != menu_id) hide_menu(i);
}
// make root level visible
for (var n_order = 0; n_order < A_MENUS[menu_id].a_children.length; n_order++)
A_MENUS[menu_id].a_children[n_order].e_oelement.style.visibility = 'visible';
}
// --------------------------------------------------------------------------------
function hide_menu(menu_id){
// make root level invisible
for (var n_order = 0; n_order < A_MENUS[menu_id].a_children.length; n_order++)
A_MENUS[menu_id].a_children[n_order].e_oelement.style.visibility = 'hidden';
}
then for your onClick event call:
onClick="show_menu(0)"
for whatever item you set this event to, it will cause it to open the menu on the first click, and close it on the second click
if you have multiple menus, 0 is the first menu loaded, 1 the second, etc. The function will close any open menus when opening a different one.
finally, you need to change the following line in the 'menu' function:
// make root level visible
for (var n_order = 0; n_order < this.a_children.length; n_order++)
this.a_children[n_order].e_oelement.style.visibility = 'visible';
to read:
// make root level invisible
for (var n_order = 0; n_order < this.a_children.length; n_order++)
this.a_children[n_order].e_oelement.style.visibility = 'hidden';
hint: the line is at the end of the function in menu.js
|
|
|