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

仿制下拉菜单有关问题

2012-03-03 
仿制下拉菜单问题在网上看到一个下拉菜单的实例,我想仿制下拉菜单这个菜单,另外增加菜单项(菜单三和菜单四

仿制下拉菜单问题
在网上看到一个下拉菜单的实例,我想仿制下拉菜单这个菜单,另外增加菜单项(菜单三和菜单四),其中菜单一和菜单二和原例子的菜单.但增加菜单三和菜单四都出现不同的问题!!弄了半天也弄不明白,请指教...(解决后马上结贴)

<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 下拉菜单 </title>
</head>

<body>
<SCRIPT   language=JavaScript>
function   MM_findObj(n,   d)   {   //v4.0
var   p,i,x;if(!d)   d=document;if((p=n.indexOf( "? "))> 0&&parent.frames.length){
d=parent.frames[n.substring(p+1)].document;   n=n.substring(0,p);}
if(!(x=d[n])&&d.all)   x=d.all[n];   for   (i=0;!x&&i <d.forms.length;i++)   x=d.forms[i][n];
for(i=0;!x&&d.layers&&i <d.layers.length;i++)   x=MM_findObj(n,d.layers[i].document);
if(!x   &&   document.getElementById)   x=document.getElementById(n);   return   x;}
function   MM_showHideLayers()   {   //v3.0
var   i,p,v,obj,args=MM_showHideLayers.arguments;
for   (i=0;   i <(args.length-2);   i+=3)   if   ((obj=MM_findObj(args[i]))!=null)   {   v=args[i+2];
if   (obj.style)   {   obj=obj.style;   v=(v== 'show ')? 'visible ':(v= 'hide ')? 'hidden ':v;   }
obj.visibility=v;   }}
//showhidelayer
function   mOvr(src,   cOvr)  
{if   (!src.contains(event.fromElement))   {src.style.cursor   =   "default ";src.bgColor   =   cOvr;}}
function   mOut(src,   cOut)  
{if   (!src.contains(event.toElement))   {src.style.cursor   =   "default ";src.bgColor   =   cOut;}}
//changetdcolor
</SCRIPT>
<table   width= "768 "   border= "1 "   align= "center ">
    <tr>
        <td>   <DIV   id=menu01   style= "POSITION:   absolute ">
                        <DIV   id=sub   onmouseout= "MM_showHideLayers( 'sub ', ' ', 'hide ') "  
                        onmouseover= "MM_showHideLayers( 'sub ', ' ', 'show ') "  
                        style= "HEIGHT:   30px;   LEFT:   -7px;   POSITION:   absolute;   TOP:   12px;   VISIBILITY:   hidden;   WIDTH:   90px;   Z-INDEX:   11 ">
<TABLE   border=0   cellPadding=4   cellSpacing=1   class=46C92F   width= "150 ">

                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  


                                                href= "sub_new.php "> 新闻时事 </A> </TD>
    </TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "stock/index.php "> 移动股市 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "sub_xingzuo.php "> 星座预测 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "weather.php "> 天气预报 </A> </TD>
</TR>
</TABLE> </DIV> </DIV>
<A  
                        class=menu   href= " "  
                        onmouseout= "MM_showHideLayers( 'sub ', ' ', 'hide ') "  
                        onmouseover= "MM_showHideLayers( 'sub ', ' ', 'show ') "> 菜单一 </A>  
</td>
        <td>     <DIV   id=menu02   style= "POSITION:   absolute ">
                        <DIV   id=mo   onmouseout= "MM_showHideLayers( 'mo ', ' ', 'hide ') "  
                        onmouseover= "MM_showHideLayers( 'mo ', ' ', 'show ') "  
                        style= "HEIGHT:   30px;   LEFT:   -7px;   POSITION:   absolute;   TOP:   12px;   VISIBILITY:   hidden;   WIDTH:   90px;   Z-INDEX:   12 ">
<TABLE   border=0   cellPadding=4   cellSpacing=1   class=46C92F   width= "150 ">


                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03   href= "mo/news.html "  
                                                target=_blank> 资讯大全0 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "mo/service.html "> 短语/图片/铃声0 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "mo/yxcs.html "> 游戏测试0 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "mo/0.html "> 纵横短信0 </A> </TD>
</TR> </TABLE> </DIV> </DIV> <A  
                        class=menu   href= "mo/ "  
                        onmouseout= "MM_showHideLayers( 'mo ', ' ', 'hide ') "  
                        onmouseover= "MM_showHideLayers( 'mo ', ' ', 'show ') "> 菜单二 </A>  
   
</td>
        <td>
<DIV   id=menu03   style= "POSITION:   absolute ">
                        <DIV   id=brand   onmouseout= "MM_showHideLayers( 'brand ', ' ', 'hide ') "  
                        onmouseover= "MM_showHideLayers( 'brand ', ' ', 'show ') "  


                        style= "HEIGHT:   30px;   LEFT:   -7px;   POSITION:   absolute;   TOP:   12px;   VISIBILITY:   hidden;   WIDTH:   90px;   Z-INDEX:   11 ">
<TABLE   border=0   cellPadding=4   cellSpacing=1   class=46C92F   width= "120 ">
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03   href= "mo/news.html "  
                                                target=_blank> 资讯大全1 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "mo/service.html "> 短语/图片/铃声1 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "mo/yxcs.html "> 游戏测试1 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "mo/0.html "> 纵横短信1 </A> </TD>
</TR> </TABLE> </DIV> </DIV> <A  
                        class=menu   href= "mo/ "  
                        onmouseout= "MM_showHideLayers( 'brand ', ' ', 'hide ') "  
                        onmouseover= "MM_showHideLayers( 'brand ', ' ', 'hide ') "> 菜单三 </A>  
</td>
        <td> <DIV   id=menu04   style= "POSITION:   absolute ">


                        <DIV   id=product   onmouseout= "MM_showHideLayers( 'product ', ' ', 'hide ') "  
                        onmouseover= "MM_showHideLayers( 'product ', ' ', 'show ') "  
                        style= "HEIGHT:   30px;   LEFT:   -7px;   POSITION:   absolute;   TOP:   12px;   VISIBILITY:   hidden;   WIDTH:   90px;   Z-INDEX:   11 ">
<TABLE   border=0   cellPadding=4   cellSpacing=1   class=46C92F   width= "120 ">
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03   href= "mo/news.html "  
                                                target=_blank> 资讯大全2 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "mo/service.html "> 短语/图片/铃声12 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "mo/yxcs.html "> 游戏测试12 </A> </TD>
</TR>
                                        <TR   bgColor=#fafef4>
                                            <TD> <A   class=pt03  
                                                href= "mo/0.html "> 纵横短信12 </A> </TD>
</TR> </TABLE> </DIV> </DIV> <A  
                        class=menu   href= " "  
                        onmouseout= "MM_showHideLayers( 'yycq ', ' ', 'hide ', 'logo ', ' ', 'hide ', 'ring ', ' ', 'hide ', 'sub ', ' ', 'hide ', 'mo ', ' ', 'hide ', 'brand ', ' ', 'hide ', 'feature ', ' ', 'hide ', 'product ', ' ', 'hide ', 'help ', ' ', 'hide ') "  


                        onmouseover= "MM_showHideLayers( 'yycq ', ' ', 'hide ', 'logo ', ' ', 'hide ', 'ring ', ' ', 'hide ', 'sub ', ' ', 'show ', 'mo ', ' ', 'hide ', 'brand ', ' ', 'hide ', 'feature ', ' ', 'hide ', 'product ', ' ', 'hide ', 'help ', ' ', 'hide ') "> 菜单四 </A>  
</td>
    </tr>
</table>
</body>
</html>


[解决办法]
試試;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 下拉菜单 </title>
</head>

<body>
<SCRIPT language=JavaScript>
function MM_findObj(n, d) { //v4.0
var p,i,x;if(!d) d=document;if((p=n.indexOf( "? "))> 0&&parent.frames.length){
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i <d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i <d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;}
function MM_showHideLayers() { //v3.0
var i,p,v,obj,args=MM_showHideLayers.arguments;

for (i=0; i <(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v== 'show ')? 'visible ':(v= 'hide ')? 'hidden ':v; }
obj.visibility=v; }}
//showhidelayer
function mOvr(src, cOvr)
{if (!src.contains(event.fromElement)) {src.style.cursor = "default ";src.bgColor = cOvr;}}
function mOut(src, cOut)
{if (!src.contains(event.toElement)) {src.style.cursor = "default ";src.bgColor = cOut;}}
//changetdcolor
</SCRIPT>
<table width= "768 " border= "1 " align= "center ">
<tr>
<td> <DIV id=menu01 style= "POSITION: absolute ">
<DIV id=sub onmouseout= "MM_showHideLayers( 'sub ', ' ', 'hide ') "
onmouseover= "MM_showHideLayers( 'sub ', ' ', 'show ') "
style= "HEIGHT: 30px; LEFT: -7px; POSITION: absolute; TOP: 12px; VISIBILITY: hidden; WIDTH: 90px; Z-INDEX: 11 ">
<TABLE border=0 cellPadding=4 cellSpacing=1 class=46C92F width= "150 ">

<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "sub_new.php "> 新闻时事 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "stock/index.php "> 移动股市 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "sub_xingzuo.php "> 星座预测 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03


href= "weather.php "> 天气预报 </A> </TD>
</TR>
</TABLE> </DIV> </DIV>
<A
class=menu href= " "
onmouseout= "MM_showHideLayers( 'sub ', ' ', 'hide ') "
onmouseover= "MM_showHideLayers( 'sub ', ' ', 'show ') "> 菜单一 </A>
</td>
<td> <DIV id=menu02 style= "POSITION: absolute ">
<DIV id=mo onmouseout= "MM_showHideLayers( 'mo ', ' ', 'hide ') "
onmouseover= "MM_showHideLayers( 'mo ', ' ', 'show ') "
style= "HEIGHT: 30px; LEFT: -7px; POSITION: absolute; TOP: 12px; VISIBILITY: hidden; WIDTH: 90px; Z-INDEX: 12 ">
<TABLE border=0 cellPadding=4 cellSpacing=1 class=46C92F width= "150 ">
<TR bgColor=#fafef4>
<TD> <A class=pt03 href= "mo/news.html "
target=_blank> 资讯大全0 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "mo/service.html "> 短语/图片/铃声0 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "mo/yxcs.html "> 游戏测试0 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "mo/0.html "> 纵横短信0 </A> </TD>
</TR> </TABLE> </DIV> </DIV> <A
class=menu href= " "
onmouseout= "MM_showHideLayers( 'mo ', ' ', 'hide ') "
onmouseover= "MM_showHideLayers( 'mo ', ' ', 'show ') "> 菜单二 </A>

</td>
<td>
<DIV id=menu03 style= "POSITION: absolute ">
<DIV id=brand onmouseout= "MM_showHideLayers( 'brand ', ' ', 'hide ') "
onmouseover= "MM_showHideLayers( 'brand ', ' ', 'show ') "
style= "HEIGHT: 30px; LEFT: -7px; POSITION: absolute; TOP: 12px; VISIBILITY: hidden; WIDTH: 90px; Z-INDEX: 11 ">
<TABLE border=0 cellPadding=4 cellSpacing=1 class=46C92F width= "120 ">
<TR bgColor=#fafef4>
<TD> <A class=pt03 href= "mo/news.html "
target=_blank> 资讯大全1 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "mo/service.html "> 短语/图片/铃声1 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "mo/yxcs.html "> 游戏测试1 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "mo/0.html "> 纵横短信1 </A> </TD>
</TR> </TABLE> </DIV> </DIV> <A
class=menu href= "mo/ "
onmouseout= "MM_showHideLayers( 'brand ', ' ', 'hide ') "


onmouseover= "MM_showHideLayers( 'brand ', ' ', 'show ') "> 菜单三 </A>
</td>
<td> <DIV id=menu04 style= "POSITION: absolute ">
<DIV id=product onmouseout= "MM_showHideLayers( 'product ', ' ', 'hide ') "
onmouseover= "MM_showHideLayers( 'product ', ' ', 'show ') "
style= "HEIGHT: 30px; LEFT: -7px; POSITION: absolute; TOP: 12px; VISIBILITY: hidden; WIDTH: 90px; Z-INDEX: 11 ">
<TABLE border=0 cellPadding=4 cellSpacing=1 class=46C92F width= "120 ">
<TR bgColor=#fafef4>
<TD> <A class=pt03 href= "mo/news.html "
target=_blank> 资讯大全2 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "mo/service.html "> 短语/图片/铃声12 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "mo/yxcs.html "> 游戏测试12 </A> </TD>
</TR>
<TR bgColor=#fafef4>
<TD> <A class=pt03
href= "mo/0.html "> 纵横短信12 </A> </TD>
</TR> </TABLE> </DIV> </DIV> <A
class=menu href= " "
onmouseout= "MM_showHideLayers( 'yycq ', ' ', 'hide ', 'logo ', ' ', 'hide ', 'ring ', ' ', 'hide ', 'sub ', ' ', 'hide ', 'mo ', ' ', 'hide ', 'brand ', ' ', 'hide ', 'feature ', ' ', 'hide ', 'product ', ' ', 'hide ', 'help ', ' ', 'hide ') "
onmouseover= "MM_showHideLayers( 'yycq ', ' ', 'show ', 'logo ', ' ', 'hide ', 'ring ', ' ', 'hide ', 'sub ', ' ', 'hide ', 'mo ', ' ', 'hide ', 'brand ', ' ', 'hide ', 'feature ', ' ', 'hide ', 'product ', ' ', 'show ', 'help ', ' ', 'show ') "> 菜单四 </A>
</td>
</tr>
</table>
</body>
</html>

热点排行