請問,下列下拉菜單為什么不能:當鼠標移開時隱藏?謝謝!
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<SCRIPT language=JavaScript>
<!--
function MM_findObj(n, d) { //v3.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); 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; }
}
//-->
</SCRIPT>
</head>
<body bgcolor="#FFFFFF">
<div id="Layer1" style="position:absolute; left:68px; top:28px; width:374px; height:297px; z-index:1"></div>
<div id="Layer2" style="position:absolute; left:88px; top:36px; width:300px; height:25px; z-index:2">
<table width="100%" border="0">
<tr>
<td height="28" bgcolor="#FFCCCC"> </td>
<td height="28" bgcolor="#CCFFCC"> </td>
</tr>
</table>
</div>
<div id="Layer3" style="position:absolute; left:104px; top:41px; width:97px; height:20px; z-index:3"><a href="#" onMouseOver="MM_showHideLayers('Layer5','','show')">dddddd</a></div>
<div id="Layer4" style="position:absolute; left:250px; top:41px; width:104px; height:21px; z-index:4"><a href="#" onMouseOver="MM_showHideLayers('Layer6','','show')">kkkkkk</a></div>
<div id="Layer5" style="position:absolute; left:106px; top:60px; width:94px; height:63px; z-index:5; visibility: hidden">
<table width="100%" border="0">
<tr>
<td><a href="#">11111</a></td>
</tr>
<tr>
<td><a href="#">22222</a></td>
</tr>
<tr>
<td><a href="#">33333</a></td>
</tr>
</table>
</div>
<div id="Layer6" style="position:absolute; left:250px; top:61px; width:104px; height:82px; z-index:6; visibility: hidden">
<table width="100%" border="0">
<tr>
<td><a href="#">aaaaa</a></td>
</tr>
<tr>
<td><a href="#">bbbbb</a></td>
</tr>
<tr>
<td><a href="#">ccccc</a></td>
</tr>
<tr>
<td><a href="#">ddddd</a></td>
</tr>
</table>
</div>
</body>
</html>
4 个解决方案
幫你改好了,回去看吧!可以結帖了.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<SCRIPT language=JavaScript>
<!--
function MM_findObj(n, d) { //v4.01
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 && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.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; }
}
//-->
</SCRIPT>
</head>
<body bgcolor="#FFFFFF">
<div id="Layer1" style="position:absolute; left:68px; top:28px; width:374px; height:297px; z-index:1"></div>
<div id="Layer2" style="position:absolute; left:88px; top:36px; width:300px; height:25px; z-index:2">
<table width="100%" border="0">
<tr>
<td height="28" bgcolor="#FFCCCC"> </td>
<td height="28" bgcolor="#CCFFCC"> </td>
</tr>
</table>
</div>
<div id="Layer3" style="position:absolute; left:104px; top:41px; width:97px; height:20px; z-index:3"><a href="#" onMouseOver="MM_showHideLayers('Layer5','','show');MM_showHideLayers('Layer6','','hide')">dddddd</a></div>
<div id="Layer4" style="position:absolute; left:250px; top:41px; width:104px; height:21px; z-index:4"><a href="#" onMouseOver="MM_showHideLayers('Layer6','','show');MM_showHideLayers('Layer5','','hide')">kkkkkk</a></div>
<div id="Layer5" style="position:absolute; left:106px; top:60px; width:94px; height:63px; z-index:5; visibility: hidden" onMouseOut="MM_showHideLayers('Layer5','','hide')" onMouseOver="MM_showHideLayers('Layer5','','show')">
<table width="100%" border="0">
<tr>
<td><a href="#">11111</a></td>
</tr>
<tr>
<td><a href="#">22222</a></td>
</tr>
<tr>
<td><a href="#">33333</a></td>
</tr>
</table>
</div>
<div id="Layer6" style="position:absolute; left:250px; top:61px; width:104px; height:82px; z-index:6; visibility: hidden" onMouseOut="MM_showHideLayers('Layer6','','hide')" onMouseOver="MM_showHideLayers('Layer6','','show')">
<table width="100%" border="0">
<tr>
<td><a href="#">aaaaa</a></td>
</tr>
<tr>
<td><a href="#">bbbbb</a></td>
</tr>
<tr>
<td><a href="#">ccccc</a></td>
</tr>
<tr>
<td><a href="#">ddddd</a></td>
</tr>
</table>
</div>
</body>
</html>
呵呵,來晚。。
代碼自己沒有細看,但自己想應該是沒有定義鼠標移開時的行為造成的吧,
好象你的代碼行為里只有:"onMouseOver" 而沒有"onMouseOut"...
它們的具體作用你可以看看Dreamweaver的幫助文檔...