GUI Components JavaScript DHTML

        "http://www.w3.org/TR/html4/strict.dtd">

    
        
        Website Left Nav Example (with submenus built from markup)
        
        
        
        
        
        
        
 
        
        
            div.yui-b p {
            
                margin:0 0 .5em 0;
                color:#999;
            
            }
            
            div.yui-b p strong {
            
                font-weight:bold;
                color:#000;
            
            }
            
            div.yui-b p em {
                color:#000;
            
            }            
            
            h1 {
                padding:.25em .5em;
                background-color:#ccc;
            }
            div.yuimenu {
            
                position:absolute;
                visibility:hidden;
            
            }
            #productsandservices {
            
                position:static;
                visibility:visible;
            
            }
        
        
        
        
        
        
        
        
        
        
        
        
            // "load" handler for the window
            YAHOO.example.onWindowLoad = function(p_oEvent) {
                // Hides submenus of the root Menu instance
                
                function hideSubmenus() {
                    if(oMenu.activeItem) {
                    
                        var oSubmenu = oMenu.activeItem.cfg.getProperty("submenu");
                        if(oSubmenu) {
                        
                            oSubmenu.hide();
                        
                        }
                    
                    }
                }
                // Cancels the call to "hideSubmenus"
                function cancelTimer() {
                    if(nTimeoutId) {
    
                        window.clearTimeout(nTimeoutId);
    
                    }
                
                }
    
    
                // "mouseout" event handler for each submenu
                
                function onSubmenuMouseOut(p_sType, p_aArguments, p_oMenu) {
    
                    cancelTimer();
    
                    nTimeoutId = window.setTimeout(hideSubmenus, 750);
                
                }
                var nTimeoutId;
                // Initialize the root menu
                var oMenu = new YAHOO.widget.Menu("productsandservices", { position: "static" });
                // Render the root menu and corresponding submenus
                oMenu.render();
                var oCommunication = oMenu.getItem(0).cfg.getProperty("submenu"),
                    oPIM = oCommunication.getItem(5).cfg.getProperty("submenu"),
                    oShopping = oMenu.getItem(1).cfg.getProperty("submenu"),
                    oEntertainment = oMenu.getItem(2).cfg.getProperty("submenu"),
                    oInformation = oMenu.getItem(3).cfg.getProperty("submenu");
                // Assign event handlers
                // Add a "mouseover" event handler to the root menu
                
                oMenu.mouseOverEvent.subscribe(cancelTimer);
                // Add a "mouseover" event handler to each submenu
                
                oCommunication.mouseOverEvent.subscribe(cancelTimer);
                oPIM.mouseOverEvent.subscribe(cancelTimer);
                oShopping.mouseOverEvent.subscribe(cancelTimer);
                oEntertainment.mouseOverEvent.subscribe(cancelTimer);
                oInformation.mouseOverEvent.subscribe(cancelTimer);
                
                // Add a "mouseout" event handler to each submenu
                oCommunication.mouseOutEvent.subscribe(onSubmenuMouseOut, oCommunication, true);
                oPIM.mouseOutEvent.subscribe(onSubmenuMouseOut, oPIM, true);
                oShopping.mouseOutEvent.subscribe(onSubmenuMouseOut, oShopping, true);
                oEntertainment.mouseOutEvent.subscribe(onSubmenuMouseOut, oEntertainment, true);
                oInformation.mouseOutEvent.subscribe(onSubmenuMouseOut, oInformation, true);
                // Add a "click" handler to the document
                YAHOO.util.Event.addListener(document, "click", hideSubmenus);
            }
            // Add a "load" handler for the window
            YAHOO.util.Event.addListener(window, "load", YAHOO.example.onWindowLoad);
        
    
    
        
            
                
                    

Website Left Nav Example (with submenus built from markup) [Examples Home]


        
                
            

            
                
                
                    
                        
                                
                        

NOTE: This example demonstrates how to build a menu with submenus created using existing markup.  Alternatively, you can add submenus to a menu using JavaScript.


                        

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sit amet metus. Nunc quam elit, posuere nec, auctor in, rhoncus quis, dui. Aliquam erat volutpat. Ut dignissim, massa sit amet dignissim cursus, quam lacus feugiat dolor, id aliquam leo tortor eget odio. Pellentesque orci arcu, eleifend at, iaculis sit amet, posuere eu, lorem. Aliquam erat volutpat. Phasellus vulputate. Vivamus id erat. Nulla facilisi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nunc gravida. Ut euismod, tortor eget convallis ullamcorper, arcu odio egestas pede, ut ornare urna elit vitae mauris. Aenean ullamcorper eros a lacus. Curabitur egestas tempus lectus. Donec et lectus et purus dapibus feugiat. Sed sit amet diam. Etiam ipsum leo, facilisis ac, rutrum nec, dignissim quis, tellus. Sed eleifend.


                        

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sit amet metus. Nunc quam elit, posuere nec, auctor in, rhoncus quis, dui. Aliquam erat volutpat. Ut dignissim, massa sit amet dignissim cursus, quam lacus feugiat dolor, id aliquam leo tortor eget odio. Pellentesque orci arcu, eleifend at, iaculis sit amet, posuere eu, lorem. Aliquam erat volutpat. Phasellus vulputate. Vivamus id erat. Nulla facilisi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nunc gravida. Ut euismod, tortor eget convallis ullamcorper, arcu odio egestas pede, ut ornare urna elit vitae mauris. Aenean ullamcorper eros a lacus. Curabitur egestas tempus lectus. Donec et lectus et purus dapibus feugiat. Sed sit amet diam. Etiam ipsum leo, facilisis ac, rutrum nec, dignissim quis, tellus. Sed eleifend.


                        
                    

                

                
                
                
                       
                            
                                
                                    Communication
                
                                        
                                            
                                                

                                                        360°
                                                        Alerts
                                                        Avatars
                                                        Groups
                                                        Internet Access
                                                        PIM
                                                        
                                                            
                                                                
                                                                    
                                                                        Yahoo! Mail
                                                                        Yahoo! Address Book
                                                                        Yahoo! Calendar
                                                                        Yahoo! Notepad
                                                                    
            
                                                            
                                                                            
                                                    
                                                    
                                                    Member Directory
                                                    Messenger
                                                    Mobile
                                                    Photos
                                                
                                            
                                              
                                    
                                    
                                    Shopping
                
                                        
                                                                
                                                

                                                        Auctions
                                                        Autos
                                                        Classifieds
                                                        Flowers & Gifts
                                                        Points
                                                        Real Estate
                                                        Travel
                                                        Wallet
                                                        Yellow Pages
                                                    

                                            
                                                            
                                    
                                    
                                    Entertainment
                
                                        
                                                                
                                                

                                                        Fantasy Sports
                                                        Games
                                                        Kids
                                                        Music
                                                        Movies
                                                        Radio
                                                        Travel
                                                        TV
                                                    
                    
                                            
                                                                                
                                    
                                    
                                    Information
                
                                        
                                                                                    
                                                

                                                        Downloads
                                                        Finance
                                                        Health
                                                        Local
                                                        Maps & Directions
                                                        My Yahoo!
                                                        News
                                                        Search
                                                        Small Business
                                                        Weather
                                                    
                    
                                            
                                                                                
                                    
                                    
                                            
                            
                        
                    
                
                
            
            
                

FOOTER: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sit amet metus. Nunc quam elit, posuere nec, auctor in, rhoncus quis, dui. Aliquam erat volutpat. Ut dignissim, massa sit amet dignissim cursus, quam lacus feugiat.


            
        
        
    

           
         
  
yui.zip( 3,714 k)