且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Popup窗口创建无限级Web页菜单(7)

更新时间:2021-07-04 00:32:47

  这一节主要说一下Menu对键盘的支持,本来不支持键盘这个菜单也完全可用了,不过还是为了和WinForm的Menu统一,所以支持了和WinForm菜单一样的操作方式。

    菜单的处理函数Menu.prototype.Keydown是在AttachEvents()方法里通过:
使用Popup窗口创建无限级Web页菜单(7)doc.attachEvent('onkeydown', this.Keydown);使用Popup窗口创建无限级Web页菜单(7)
来attach的,为什么要使用onkeydown不用onkeypress呢?是为了让菜单通过键盘快捷键来弹出子菜单时和WinForm方式菜单一样。这个doc是该菜单的popup窗口的doucment对象。

    下面一边看代码一边讲吧:
使用Popup窗口创建无限级Web页菜单(7)    if ( !evt || !evt.srcElement )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        return;
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)    var menuBody = evt.srcElement;
使用Popup窗口创建无限级Web页菜单(7)    var menuHtml = FindChildElement(menuBody, 'TABLE');
使用Popup窗口创建无限级Web页菜单(7)    if ( !menuHtml || !menuHtml.uniqueId )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        menuHtml = FindParentElement(menuBody, 'TABLE');
使用Popup窗口创建无限级Web页菜单(7)        if ( !menuHtml || !menuHtml.uniqueId )
使用Popup窗口创建无限级Web页菜单(7)        {
使用Popup窗口创建无限级Web页菜单(7)            return;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)    var menuObj = __MenuCache__[menuHtml.uniqueId];
使用Popup窗口创建无限级Web页菜单(7)    if ( menuObj.HasSubMenuExpanded() )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        return;
使用Popup窗口创建无限级Web页菜单(7)    }
    由于onkeydown事件处理函数attach在document上,所以要得到菜单必须寻找body里面的Table element,不过这个evt.srcElement可能是body,也可能是table的里的元素,关键是看当时菜单popup里的焦点在那个element上。上面代码的最后4句话是判断响应onkeydown事件的菜单是否有子菜单expanded,因为我们只让最后一级显示的子菜单处理keystroke,父级的必须忽略,否则就乱套了。
使用Popup窗口创建无限级Web页菜单(7)    if ( menuObj.m_ShowTimer )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        window.clearTimeout(menuObj.m_ShowTimer);
使用Popup窗口创建无限级Web页菜单(7)        menuObj.m_ShowTimer = null;
使用Popup窗口创建无限级Web页菜单(7)    }
    这是用来支持子菜单显示特效的一个timer,如果手动显示子菜单(包括鼠标click和键盘快捷键),清除这个timer。

使用Popup窗口创建无限级Web页菜单(7)    var activeIndex = -1;
使用Popup窗口创建无限级Web页菜单(7)    for ( var i=0 ; i < menuObj.m_Items.length ; ++i )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        if ( menuObj.m_ActiveItem == menuObj.m_Items[i] )
使用Popup窗口创建无限级Web页菜单(7)        {
使用Popup窗口创建无限级Web页菜单(7)            activeIndex = i;
使用Popup窗口创建无限级Web页菜单(7)            break;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)    }
    把菜单中已active的item的index搜索出来,没有active的menuitem,index为-1。

使用Popup窗口创建无限级Web页菜单(7)    var sign = -1; 
使用Popup窗口创建无限级Web页菜单(7)    switch( evt.keyCode )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        case 37 : // left
使用Popup窗口创建无限级Web页菜单(7)
        {
使用Popup窗口创建无限级Web页菜单(7)            if ( menuObj.m_ParentMenu )
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                menuObj.Hide();
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)            break;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        case 38 : // up | no break;
使用Popup窗口创建无限级Web页菜单(7)
        {
使用Popup窗口创建无限级Web页菜单(7)            sign = 1;
使用Popup窗口创建无限级Web页菜单(7)            if ( activeIndex == -1 )
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                activeIndex = 0;
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        case 40 : // down
使用Popup窗口创建无限级Web页菜单(7)
        {
使用Popup窗口创建无限级Web页菜单(7)            var itemCount = menuObj.m_Items.length;
使用Popup窗口创建无限级Web页菜单(7)            for ( var i=1 ; i <= itemCount ; ++i )
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                var index = (itemCount+activeIndex-i*sign)%itemCount;
使用Popup窗口创建无限级Web页菜单(7)                var item = menuObj.m_Items[index];
使用Popup窗口创建无限级Web页菜单(7)                if ( !item.m_Disabled && item.m_Text != '-' )
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.__resumeItem();
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.m_ActiveItem = item;
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.__activeItem();
使用Popup窗口创建无限级Web页菜单(7)                    break;
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)            break;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        case 39 : // right | no break;
使用Popup窗口创建无限级Web页菜单(7)
        {
使用Popup窗口创建无限级Web页菜单(7)            var activeItem = menuObj.m_ActiveItem; 
使用Popup窗口创建无限级Web页菜单(7)            if ( !activeItem || !activeItem.m_ChildMenu )
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                break;
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        case 13 : // enter
使用Popup窗口创建无限级Web页菜单(7)
        {
使用Popup窗口创建无限级Web页菜单(7)            menuObj.Click();
使用Popup窗口创建无限级Web页菜单(7)            break;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        case 27 :
使用Popup窗口创建无限级Web页菜单(7)        {
使用Popup窗口创建无限级Web页菜单(7)            break;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)    }
    处理left, right, up, down四个键,up和down要麻烦些,因为要查找可用的(separator item和disabled item是不可用的,不能被active)下一个itme来active,到了最有一条itme再同方向up或down还需要有轮转的效果。
    HACK: 由于up和down的代码完全相同,只是搜索方向不同,所以用了一个sign(取值1|-1)标志来判断搜索方向。

使用Popup窗口创建无限级Web页菜单(7)    if ( evt.keyCode >= 48 && evt.keyCode <= 90 )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        var keyList = '';
使用Popup窗口创建无限级Web页菜单(7)        var key = String.fromCharCode(evt.keyCode); 
使用Popup窗口创建无限级Web页菜单(7)        for ( var i=0 ; i < menuObj.m_Items.length ; ++i )
使用Popup窗口创建无限级Web页菜单(7)        {
使用Popup窗口创建无限级Web页菜单(7)            var item = menuObj.m_Items[i];
使用Popup窗口创建无限级Web页菜单(7)            if ( !item.m_Disabled && item.m_Mnemonic )
使用Popup窗口创建无限级Web页菜单(7)            { 
使用Popup窗口创建无限级Web页菜单(7)                keyList += item.m_Mnemonic;
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)            else
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                keyList += '-';
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        var index = keyList.indexOf(key); 
使用Popup窗口创建无限级Web页菜单(7)        if ( index != -1 )
使用Popup窗口创建无限级Web页菜单(7)        { 
使用Popup窗口创建无限级Web页菜单(7)            if ( keyList.indexOf(key) == keyList.lastIndexOf(key) )
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                if ( !menuObj.m_Items[index].m_Disabled )
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.__resumeItem(); 
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.m_ActiveItem = menuObj.m_Items[index];
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.__activeItem();
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.Click();
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)            else
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                menuObj.__resumeItem();
使用Popup窗口创建无限级Web页菜单(7)                var newActive;
使用Popup窗口创建无限级Web页菜单(7)                if ( !evt.shiftKey )
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    newActive = keyList.indexOf(key, activeIndex+1);
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)                else
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    if ( activeIndex == 0 )
使用Popup窗口创建无限级Web页菜单(7)                    {
使用Popup窗口创建无限级Web页菜单(7)                        newActive = -1;
使用Popup窗口创建无限级Web页菜单(7)                        index = keyList.lastIndexOf(key);
使用Popup窗口创建无限级Web页菜单(7)                    }
使用Popup窗口创建无限级Web页菜单(7)                    else 
使用Popup窗口创建无限级Web页菜单(7)                    {
使用Popup窗口创建无限级Web页菜单(7)                        newActive = keyList.lastIndexOf(key, activeIndex-1);
使用Popup窗口创建无限级Web页菜单(7)                    }
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)                     
使用Popup窗口创建无限级Web页菜单(7)                if ( newActive == -1 )
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.m_ActiveItem = menuObj.m_Items[index];
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)                else
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.m_ActiveItem = menuObj.m_Items[newActive];
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)                menuObj.__activeItem();
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)
    处理菜单条目上的快捷键Mnemonic,这里的算法是这样的,把该菜单上的每个item上的Mnemonic字符取出组成一个字符串,没有Mnemonic就用'-'代替。比如下面的菜单的Mnemonic字符组成的字符串分别是:
   使用Popup窗口创建无限级Web页菜单(7) 
    第一级:"--N---",第二级:"M",第三级:"TTTT"。然后使用String.indexOf(key)就取到被按快捷键的MenuItem的index了,由于没有限制同一个Menu里面多个MenuItem具有相同的Mnemonic,所以像第三级菜单,一直按T键的效果就和按down key一样,它的效果使用语句Sting.indexOf(key, activeIndex+1)来获得。 

使用Popup窗口创建无限级Web页菜单(7)#region 附Menu.prototype.Keydown = function(evt)代码 
使用Popup窗口创建无限级Web页菜单(7)Menu.prototype.Keydown = function(evt)
使用Popup窗口创建无限级Web页菜单(7){
使用Popup窗口创建无限级Web页菜单(7)    if ( !evt || !evt.srcElement )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        return;
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)    var menuBody = evt.srcElement;
使用Popup窗口创建无限级Web页菜单(7)    var menuHtml = FindChildElement(menuBody, 'TABLE');
使用Popup窗口创建无限级Web页菜单(7)    if ( !menuHtml || !menuHtml.uniqueId )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        menuHtml = FindParentElement(menuBody, 'TABLE');
使用Popup窗口创建无限级Web页菜单(7)        if ( !menuHtml || !menuHtml.uniqueId )
使用Popup窗口创建无限级Web页菜单(7)        {
使用Popup窗口创建无限级Web页菜单(7)            return;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)    var menuObj = __MenuCache__[menuHtml.uniqueId];
使用Popup窗口创建无限级Web页菜单(7)    if ( menuObj.HasSubMenuExpanded() )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        return;
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)
使用Popup窗口创建无限级Web页菜单(7)    if ( menuObj.m_ShowTimer )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        window.clearTimeout(menuObj.m_ShowTimer);
使用Popup窗口创建无限级Web页菜单(7)        menuObj.m_ShowTimer = null;
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)
使用Popup窗口创建无限级Web页菜单(7)    var activeIndex = -1;
使用Popup窗口创建无限级Web页菜单(7)    for ( var i=0 ; i < menuObj.m_Items.length ; ++i )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        if ( menuObj.m_ActiveItem == menuObj.m_Items[i] )
使用Popup窗口创建无限级Web页菜单(7)        {
使用Popup窗口创建无限级Web页菜单(7)            activeIndex = i;
使用Popup窗口创建无限级Web页菜单(7)            break;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)    var sign = -1; 
使用Popup窗口创建无限级Web页菜单(7)    switch( evt.keyCode )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        case 37 : // left
使用Popup窗口创建无限级Web页菜单(7)
        {
使用Popup窗口创建无限级Web页菜单(7)            if ( menuObj.m_ParentMenu )
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                menuObj.Hide();
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)            break;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        case 38 : // up | no break;
使用Popup窗口创建无限级Web页菜单(7)
        {
使用Popup窗口创建无限级Web页菜单(7)            sign = 1;
使用Popup窗口创建无限级Web页菜单(7)            if ( activeIndex == -1 )
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                activeIndex = 0;
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        case 40 : // down
使用Popup窗口创建无限级Web页菜单(7)
        {
使用Popup窗口创建无限级Web页菜单(7)            var itemCount = menuObj.m_Items.length;
使用Popup窗口创建无限级Web页菜单(7)            for ( var i=1 ; i <= itemCount ; ++i )
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                var index = (itemCount+activeIndex-i*sign)%itemCount;
使用Popup窗口创建无限级Web页菜单(7)                var item = menuObj.m_Items[index];
使用Popup窗口创建无限级Web页菜单(7)                if ( !item.m_Disabled && item.m_Text != '-' )
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.__resumeItem();
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.m_ActiveItem = item;
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.__activeItem();
使用Popup窗口创建无限级Web页菜单(7)                    break;
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)            break;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        case 39 : // right | no break;
使用Popup窗口创建无限级Web页菜单(7)
        {
使用Popup窗口创建无限级Web页菜单(7)            var activeItem = menuObj.m_ActiveItem; 
使用Popup窗口创建无限级Web页菜单(7)            if ( !activeItem || !activeItem.m_ChildMenu )
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                break;
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        case 13 : // enter
使用Popup窗口创建无限级Web页菜单(7)
        {
使用Popup窗口创建无限级Web页菜单(7)            menuObj.Click();
使用Popup窗口创建无限级Web页菜单(7)            break;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        case 27 :
使用Popup窗口创建无限级Web页菜单(7)        {
使用Popup窗口创建无限级Web页菜单(7)            break;
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)    if ( evt.keyCode >= 48 && evt.keyCode <= 90 )
使用Popup窗口创建无限级Web页菜单(7)    {
使用Popup窗口创建无限级Web页菜单(7)        var keyList = '';
使用Popup窗口创建无限级Web页菜单(7)        var key = String.fromCharCode(evt.keyCode); 
使用Popup窗口创建无限级Web页菜单(7)        for ( var i=0 ; i < menuObj.m_Items.length ; ++i )
使用Popup窗口创建无限级Web页菜单(7)        {
使用Popup窗口创建无限级Web页菜单(7)            var item = menuObj.m_Items[i];
使用Popup窗口创建无限级Web页菜单(7)            if ( !item.m_Disabled && item.m_Mnemonic )
使用Popup窗口创建无限级Web页菜单(7)            { 
使用Popup窗口创建无限级Web页菜单(7)                keyList += item.m_Mnemonic;
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)            else
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                keyList += '-';
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)        var index = keyList.indexOf(key); 
使用Popup窗口创建无限级Web页菜单(7)        if ( index != -1 )
使用Popup窗口创建无限级Web页菜单(7)        { 
使用Popup窗口创建无限级Web页菜单(7)            if ( keyList.indexOf(key) == keyList.lastIndexOf(key) )
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                if ( !menuObj.m_Items[index].m_Disabled )
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.__resumeItem(); 
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.m_ActiveItem = menuObj.m_Items[index];
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.__activeItem();
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.Click();
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)            else
使用Popup窗口创建无限级Web页菜单(7)            {
使用Popup窗口创建无限级Web页菜单(7)                menuObj.__resumeItem();
使用Popup窗口创建无限级Web页菜单(7)                var newActive;
使用Popup窗口创建无限级Web页菜单(7)                if ( !evt.shiftKey )
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    newActive = keyList.indexOf(key, activeIndex+1);
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)                else
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    if ( activeIndex == 0 )
使用Popup窗口创建无限级Web页菜单(7)                    {
使用Popup窗口创建无限级Web页菜单(7)                        newActive = -1;
使用Popup窗口创建无限级Web页菜单(7)                        index = keyList.lastIndexOf(key);
使用Popup窗口创建无限级Web页菜单(7)                    }
使用Popup窗口创建无限级Web页菜单(7)                    else 
使用Popup窗口创建无限级Web页菜单(7)                    {
使用Popup窗口创建无限级Web页菜单(7)                        newActive = keyList.lastIndexOf(key, activeIndex-1);
使用Popup窗口创建无限级Web页菜单(7)                    }
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)                     
使用Popup窗口创建无限级Web页菜单(7)                if ( newActive == -1 )
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.m_ActiveItem = menuObj.m_Items[index];
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)                else
使用Popup窗口创建无限级Web页菜单(7)                {
使用Popup窗口创建无限级Web页菜单(7)                    menuObj.m_ActiveItem = menuObj.m_Items[newActive];
使用Popup窗口创建无限级Web页菜单(7)                }
使用Popup窗口创建无限级Web页菜单(7)                menuObj.__activeItem();
使用Popup窗口创建无限级Web页菜单(7)            }
使用Popup窗口创建无限级Web页菜单(7)        }
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)    if ( evt.keyCode != 27 )
使用Popup窗口创建无限级Web页菜单(7)    {  
使用Popup窗口创建无限级Web页菜单(7)        evt.returnValue = null;
使用Popup窗口创建无限级Web页菜单(7)        evt.cancelBubble = true
使用Popup窗口创建无限级Web页菜单(7)    }
使用Popup窗口创建无限级Web页菜单(7)};

    to be continued ...

本文转自博客园鸟食轩的博客,原文链接:http://www.cnblogs.com/birdshome/,如需转载请自行联系原博主。