GUI Components JavaScript DHTML

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

    
        
        Example 2: Basic Menu From Pure JavaScript
        
        
        
        
        
 
        
        
            body { margin:.5em; }
        
        
        
        
        
        
        
        
        
        
        
        
            YAHOO.example.onWindowLoad = function(p_oEvent) {
                var oMenu = new YAHOO.widget.Menu("basicmenu", { fixedcenter: true });
                oMenu.addItem(
                        new YAHOO.widget.MenuItem(
                            "Yahoo! Mail", 
                            { url:"http://mail.yahoo.com"}
                        )
                    );
                oMenu.addItem(
                        new YAHOO.widget.MenuItem(
                            "Yahoo! Address Book", 
                            { url:"http://addressbook.yahoo.com"}
                        )
                    );
                oMenu.addItem(
                        new YAHOO.widget.MenuItem(
                            "Yahoo! Calendar", 
                            { url:"http://calendar.yahoo.com"}
                        )
                    );
                oMenu.addItem(
                        new YAHOO.widget.MenuItem(
                            "Yahoo! Notepad", 
                            { url:"http://notepad.yahoo.com"} 
                        )
                    );
                oMenu.render(document.body);
    
                oMenu.show();
            }
            YAHOO.util.Event.addListener(window, "load", YAHOO.example.onWindowLoad);
            
        
    
    
        

Example 2: Basic Menu From Pure JavaScript [Examples Home]


        

This example demonstrates how to create a basic menu using nothing but JavaScript.  The Menu API also supports building a menu like this using existing markup.


    

           
         
  
yui.zip( 3,714 k)