首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

动态下拉菜单如何样才能默认打开

2012-02-24 
动态下拉菜单怎么样才能默认打开下拉菜单的代码是:scoresnewArray(20)varnumTotal0NS4(document.laye

动态下拉菜单怎么样才能默认打开
下拉菜单的代码是:
scores   =   new   Array(20);
var   numTotal=0;
NS4   =   (document.layers)   ?   1   :   0;
IE4   =   (document.all)   ?   1   :   0;
ver4   =   (NS4   ||   IE4)   ?   1   :   0;


function   getIndex(el)   {
        ind   =   null;
        for   (i=0;   i <document.layers.length;   i++)   {
                whichEl   =   document.layers[i];
                if   (whichEl.id   ==   el)   {
                        ind   =   i;
                        break;
                }
        }
        return   ind;
}

function   arrange()   {
        nextY   =   document.layers[firstInd].pageY   +document.layers[firstInd].document.height;
        for   (i=firstInd+1;   i <document.layers.length;   i++)   {
                whichEl   =   document.layers[i];
                if   (whichEl.visibility   !=   "hide ")   {
                        whichEl.pageY   =   nextY;
                        nextY   +=   whichEl.document.height;
                }
        }
}

function   initIt(){
        if   (!ver4)   return;
        if   (NS4)   {
                for   (   i=0;   i <document.layers.length;   i++)   {
                        whichEl   =   document.layers[i];
                        if   (whichEl.id.indexOf( "Child ")   !=   -1)   whichEl.visibility   =   "hide ";
              }
                arrange();
        }
        else   {
                divColl   =   document.all.tags( "DIV ");
                for   (   i=0;   i <divColl.length;   i++)   {
                        whichEl   =   divColl(i);
                        if   (whichEl.className   ==   "child ")   whichEl.style.display   =   "none ";
                }
        }
}

function   expandIt(el)   {
if   (!ver4)   return;
        if   (IE4)   {


                whichEl1   =   eval(el   +   "Child ");
for(i=1;i <=numTotal;i++){
whichEl   =   eval(scores[i]   +   "Child ");
if(whichEl!=whichEl1)   {
whichEl.style.display   =   "none ";
}
}
                whichEl1   =   eval(el   +   "Child ");
                if   (whichEl1.style.display   ==   "none ")   {
                        whichEl1.style.display   =   "block ";
                }
                else   {
                        whichEl1.style.display   =   "none ";
                }
        }
        else   {
                whichEl   =   eval( "document. "   +   el   +   "Child ");
for(i=1;i <=numTotal;i++){
whichEl   =   eval( "document. "   +   scores[i]   +   "Child ");
if(whichEl!=whichEl1)   {
whichEl.visibility   =   "show ";
}
}
                if   (whichEl.visibility   ==   "show ")   {
                        whichEl.visibility   =   "show ";
                }
                else   {
                        whichEl.visibility   =   "show ";
                }
                arrange();
        }
}
onload   =   initIt;


提取数据语句是: <SCRIPT   language=JavaScript   >

var   ALLS=0;

function   app(txt)   {
ALLS   =   ALLS+1;
n=ALLS;
document.write(   " <IMG   SRC= '/images/kong.gif '     width=\ "10\ "   height=\ "6\ "> <br> <div   id= 'KB "+n+ "Parent '> <a   href=\ "Default.asp\ "   onClick=\ "expandIt( 'KB "+n+ " ');   return   false\ "> "+
                                " <IMG   SRC= '/images/+.gif '   BORDER=0     align=\ "absmiddle\ "   >   "+txt+ " </a> </div> <div   id= 'KB "+n+ "Child '   class= 'child '> ");
}

该菜单默认是关闭的,怎么样才能默认打开状态


[解决办法]
注释掉initIt函数中
if (whichEl.id.indexOf( "Child ") != -1) whichEl.visibility = "hide ";

if (whichEl.className == "child ") whichEl.style.display = "none ";

热点排行