javascript輕松實現(xiàn)當鼠標移開時已彈出子菜單自動消失
更新時間:2013年12月29日 16:27:05 作者:
本文為大家詳細介紹下使用javascript實現(xiàn)當鼠標移開時已彈出子菜單自動消失,具體如下,感興趣的朋友不要錯過
復制代碼 代碼如下:
<html>
<head>
<style type="text/css">
.menu
{
background-color:green;
width:120;
height:20;
color: white;
text-align: center;
font-size:9pt;
font-weight:bolder;
}
.submenu
{
position:absolute;
top:40;
background-color:
yellow;width:180;
font-size:9pt;
}
</style>
</head>
<body>
<SCRIPT>
var cm=null;
document.onclick = new Function("show(null)")
function getPos(el,sprop)
{var iPos = 0
while (el!=null)
{iPos+=el["offset" + sprop]
el = el.offsetParent}
return iPos}
function show(el,m)
{if (m) { m.style.display='';
m.style.pixelLeft = getPos(el,"Left")
m.style.pixelTop = getPos(el,"Top") + el.offsetHeight}
if ((m!=cm) && (cm)) cm.style.display='none';cm=m}
</SCRIPT>
<table border=0>
<tr>
<td ID="d1" onmouseover="show(this,ds1);" class="menu">雜志技術站點</td>
<td ID="d2" onmouseover="show(this,ds2);" class="menu">門戶站點</td>
<td ID="d3" onmouseover="show(this,ds3);" class="menu">個人收藏站點</td>
</tr>
</table>
<DIV ID="ds1" CLASS="submenu" STYLE="display:none" onmouseleave="this.style.display='none'">
<BR><A >天極網(wǎng) Yesky.com</A>
<BR><A >電腦商情報</A>
<BR><A >新潮電子</A>
<BR>
</DIV>
<DIV ID="ds2" CLASS="submenu" STYLE="display:none" onmouseleave="this.style.display='none'">
<BR><A >新浪網(wǎng) Sina</A>
<BR><A >搜狐 Sohu</A>
<BR><A >網(wǎng)易 Netease</A>
<BR>
</DIV>
<DIV ID="ds3" CLASS="submenu" STYLE="display:none" onmouseleave="this.style.display='none'">
<BR><A >耗子網(wǎng)絡編程站</A>
<BR><A >中國同學錄</A>
<BR><A >中國軟件開發(fā)網(wǎng)</A>
<BR>
</DIV>
</body>
</html>
相關文章
用javascript實現(xiàn)點擊鏈接彈出"圖片另存為"而不是直接打開
用javascript實現(xiàn)點擊鏈接彈出"圖片另存為"而不是直接打開...2007-08-08