程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> ASP技巧 >> WEB頁面實現淡入淡出菜單

WEB頁面實現淡入淡出菜單

編輯:ASP技巧

(本文適合菜級網頁制作者或初級WEB編程者閱讀參考)
下面的程序還是簡單的測試版。需要編程的整個思路和具體分析步驟的請Email到[email protected]

<Html>
<head>
<meta http-equiv="Content-Type" content="text/Html; charset=gb2312">
<title> 淡入淡出菜單演示 </title>
<style>
.sml_menu {font-size: 9pt; color: white; cursor: hand; font-family: Tahoma;}
.font3 {font-size: 10.5pt; color: 147e19; font-family: CourIEr New;}
.menuitem {font-size: 10.5pt; color: white; cursor: default; font-family: CourIEr New;}
</style>
<script language="Javascript">
//LiveMenu Ver1.0 by [email protected]
//2000.11
var intDelay=50; //設置菜單顯示速度,越大越慢,不超過100為好
var intInterval=5; //每次更改的透明度,最好小於10
//以下代碼需要改的地方可以更改
function MenuClick()
{
if (LayerMenu.style.display=="")
{
LayerMenu.style.display="none"; //當菜單顯示的時候單擊就關閉菜單
}
else{
LayerMenu.filters.alpha.opacity=0;
LayerMenu.style.display="";
GradIEntShow(); //淡入
  }
}

function GradIEntShow() //實現淡入的函數
{
LayerMenu.filters.alpha.opacity+=intInterval;
if (LayerMenu.filters.alpha.opacity<100) setTimeout("GradIEntShow()",intDelay);
}

function GradIEntClose() //實現淡出的函數
{
LayerMenu.filters.alpha.opacity-=intInterval;
if (LayerMenu.filters.alpha.opacity>0) {
  setTimeout("GradIEntClose()",intDelay);
  }
else {
  LayerMenu.style.display="none"; //當看不到菜單層後還需要把這個層隱藏起來
  }
}

function ChangeBG() //改變菜單項的背景顏色,這裡的兩種顏色值可以改為你需要的
{
oEl=event.srcElement;
if (oEl.style.background!="navy") {
  oEl.style.background="navy";
  }
  else {
  oEl.style.background="#147e19";
  }
}

function ItemClick() //在菜單項上單擊後打開相應鏈接
{
oEl=event.srcElement;
oLink=oEl.all.tags( "A" );
if( oLink.length )
{
oLink[0].click();
GradIEntClose();
}
}
</script>
</head>
<body onMouSEOver="GradIEntClose();">
<br>
<p align=center class=font3>LiveMenu V1.0 by [email protected]<br>請查看源代碼<br>
請手動設置菜單層或菜單提示層的具體位置<br>
在:  處設置</p>
<!--菜單提示層開始-->
<div onClick="MenuClick()">
<table border=0 cellpadding=0 cellspacing=0 width=300><tr><td bgcolor=#147e19 class=sml_menu height=20 onselectstart="return false;">&nbsp;Click here to show the menu ... (單擊顯示菜單)</td></tr></table>
</div>
<!--菜單提示層結束-->
</body>
<!--菜單層開始-->
<div id=LayerMenu oncontextmenu="return false" onMouSEOver="window.event.cancelBubble = true;">
<!--上面一行的onMouSEOver事件是很關鍵的-->
<table border=0 cellpadding=0 cellspacing=0 bgcolor=147e19>
<tr><td height=1 bgcolor=#f0f0f0 colspan=2></td></tr>
<tr><td width=20 valign=bottom bgcolor=navy></td>
<td>
<table border=0 width=200 cellpadding=0 cellspacing=0 onselectstart="return false;" onclick="ItemClick();" onMouseover="ChangeBG();" onMouSEOut="ChangeBG();">
  <tr><td class=menuitem height=20 ><a href=/First></a>1.The First Menu Item</td></tr>
  <tr><td class=menuitem height=20 ><a href=/Second></a>2.The Second Menu Item</td></tr>
  <tr><td class=menuitem height=20 >3.The Third Menu Item</td></tr>
  <tr><td class=menuitem height=20 >4.The Fourth Menu Item</td></tr>
</table>
</td></tr>
</table>
</div>
<!--菜單層結束-->
</Html>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved