許多網友問:鼠標移上去會變亮的菜單是怎么制作的?其實這是用兩張圖片交替顯示的效果,具體采用javascript腳本語言實現。因為稍微復雜些,需要細細講解。
你要制作這種效果的話,首先也要制作好同樣大小,不同效果的兩張圖片(先作好一張,再復制出另一張,再作其他效果,這樣可以保證圖片完全吻合)。
然后將下面的Javascript代碼加入到HTML的<head></head>之間
<script language="JavaScript">
// Author: Alone ^_^;
// Date: 08.26.98
// Hide from non-javascript compatible browser
j=document.images;
if (j)
{
button00=new Image(); button00.src="../images/2.gif";
button001=new Image(); button001.src="../images/21.gif";
button01=new Image(); button01.src="../images/3.gif";
button011=new Image(); button011.src="../images/31.gif";
button02=new Image(); button02.src="../images/4.gif";
button021=new Image(); button021.src="../images/41.gif";
button03=new Image(); button03.src="../images/5.gif";
button031=new Image(); button031.src="../images/51.gif";
button04=new Image(); button04.src="../images/6.gif";
button041=new Image(); button041.src="../images/61.gif";
}
function img_act(p)
{if (j) {on = eval (p + "1.src");
document[p].src = on;}
}
function img_inact(p)
{if (j) {off = eval (p + ".src");
document[p].src = off;
}
}
// --></script>
只可以將其中類似“../images/2.gif” 的語句修改為你的圖片名和路徑名,其他不要改動。再將下面的代碼放入<body></body>之間:
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" bgcolor="#000000"><p align="center"><a href="../frontpage.htm" onmouseover="img_act('button00')" onmouseout="img_inact('button00')"><img src="../images/2.gif" name="button00" alt="Frontpage寶典" border="0" WIDTH="130" HEIGHT="25"></a></td>
</tr>
<tr>
<td width="100%" bgcolor="#000000"><p align="center"><a href="../photoshop.htm" onmouseover="img_act('button01')" onmouseout="img_inact('button01')"><img src="../images/3.gif" alt="Photoshop點睛" name="button01" border="0" WIDTH="130" HEIGHT="25"></a></td>
</tr>
<tr>
<td width="100%" bgcolor="#000000"><p align="center"><a href="../javas.htm" onmouseover="img_act('button02')" onmouseout="img_inact('button02')"><img src="../images/4.gif" name="button02" alt="javascript超市" border="0" WIDTH="130" HEIGHT="25"></a></td>
</tr>
<tr>
<td width="100%" bgcolor="#000000"><p align="center"><a href="../cgi.htm" onmouseover="img_act('button03')" onmouseout="img_inact('button03')"><img src="../images/5.gif" name="button03" alt="CGI&perl天書" border="0" WIDTH="130" HEIGHT="25"></a></td>
</tr>
<tr>
<td width="100%" bgcolor="#000000"><p align="center"><a href="../homepage.htm" onmouseover="img_act('button04')" onmouseout="img_inact('button04')"><img src="../images/6.gif" name="button04" alt="Homepage技巧" border="0" WIDTH="130" HEIGHT="25"></a></td>
</tr>
</table>
將其中類似<a href="../frontpage.htm>的語句改為你需要鏈接的文件名;類似img src="../images/6.gif"的語句改為你的圖片名和路徑名;類似WIDTH="130" HEIGHT="25"的語句改為你的圖片的寬和高。