| |
| |
| |
Sample 5: Menu in Frame
Though not everybody likes frames, frames make it possible to load the scripts once and re-use later. In G2, the core script and the menu contents are loaded into the frameset, when a frame wants to show some menus, it loads the control scripts(much smaller in file size) and asks the frameset to build the menus for it.
Usually you'll have to go through the frameset tree to reach something belongs to a particular frame. In G2, you don't need to specify the name for a frame in its parent frameset, you let the control script register its frame to the top level frameset by calling the following function:
... and you can then refer from one frame to menus in other frames easily without concerning about how the frames are nested.
G2 provides you the following functions to operate from one frame the menus in other frames:
You can put these functions as the mouse-over/out event handlers for links in a frame to open and close menus in some other frames. Usually when a menu is opened in a frame, it will close all other menus in the same frame, thus actually the "closeMenu()" function is seldom used.
To work fully with cross-frame menus, G2 also provides some new types of menu items with which you can specify js codes for the mouse-over/out events. So, you guessed, you can have one menu in a frame to control other menus in other frames, just like what I did in this sameple.
In this sample, the left frame(background in blue) has a one-level pull-down menu(aligned to the right with the "1 x 1 table") with 3 menu items(Menu-A, B and C). The right frame(background in white, which you are reading) has 3 floating pull-down menus which are set to invisible initially. When your mouse is hovering the menu in the left frame, it opens the corresponding menus in the right frame.