NlsMenu Pro
addobject.com
Cross Frame Menu
NlsMenu Professional - Advanced Javascript Drop Down Menu Control
   

NlsMenu supports cross frame menu. Cross frame menu basically is defining the menubar in a frame and all its submenus in another frame. Here below is the example to configure the cross frame menu.

1. The Menubar

  • Create menu manager instance (NlsMenuManager).
  • Set the associate menu manager (the menu manager in another frame).
  • Create menubar and it's items, point the submenu to menu in another frame.

            var menuMgr = new NlsMenuManager("menubarMgr");

            //set the associate frame and menu manager located in the other frame (submenusMgr)
            menuMgr.addAssocMenuMgr(parent.contentFrame, "submenusMgr");

            //construct menubar
            var mbar = menuMgr.createMenubar("menubar");

            mbar.addItem("1", "Home", "", "");

            mbar.addItem("2", "Products", "", "", true, null);

            //add submenu using addSubmenu() function and specify the cross frame parameters.
            mbar.addSubmenu("2", "products", true, parent.contentFrame, ["REL", 0], [0,0]);

            mbar.addItem("3", "Downloads", "", "", true, null, "download");

            //add submenu using addSubmenu() function and specify the cross frame parameters.
            mbar.addSubmenu("3", "downloads", true, parent.contentFrame, ["REL", 0], [0,0]);
          

When adding submenu to the menu item, you have to specify the crsFrame, subFrame and subPos arguments.

  • crsFrame: true, indicates the submenu is located in other frame.
  • subFrame: the associate frame. In the example above, the associate frame is contentFrame.
  • subPos: the position of submenu in associate frame. The value must be an array with 2 element [x position, y position].
    The special value 'REL' indicates the position will be calculated based on menu item position. In the example above, the X position of submenu is relative to X position of menu item
For more information about the addSubmenu() function and its arguments, please find "Reference"


2. The Submenu

There is nothing special when defining submenus except you need to add associate frame and menu manager in the other frame. Then you can create the submenus as usual.


            var menuMgr = new NlsMenuManager("submenusMgr");

            //set the associate frame and menu manager located in the other frame (menubarMgr)
            menuMgr.addAssocMenuMgr(parent.topFrame, "menubarMgr");

            var prodMenu=menuMgr.createMenu("products");
            prodMenu.addItem("1", "JavaScript", "", "", true, null);
            prodMenu.addItem("2", "ASP/ASP.NET", "", "", true, null);
            prodMenu.addItem("5", "Other", "", "", true, null);

            var dloadMenu = menuMgr.createMenu("downloads");
            dloadMenu .addItem("1", "NlsTree Standard", "", "");
            dloadMenu .addItem("2", "NlsScroller Standard", "", "");