如题所示,我想建立一个导航栏,当鼠标移到图象时是一幅图象, 移开时又是另外一幅图象. 我编了一个程序, 可运行不出来. <html> <head><title>mouse rollover examples</title> <meta http-equiv"Conten-Type"conten="text/html";charset="gb2312"/> <script language="JavaScript"> <!--hide this script from non-JavaScript-enabled browsers function displaymsg(message){ window.status=message } function preloadimages(){ if(document.images){ var imgfiles=preloadimages.arguments; var preloadArray=new Array(); for(var i=0;i<imgfiles.length;i++) { preloadArray=new image; preloadArray[i].src=imgfiles[i]; } } } function swap(id,newscr) { var theimage=locateimage(id); if(theimage){ thelmage.src=newsrc; } } function locateimage(name) { var theimage=false; if(document.images) { theimage=document.images[name]; } if(theimage){ return theimage; } return(false); } //stop hiding--> </script> </head> <body bgcolor="#000000"text="#FFFFFF"link="#FFFFFF"vlink="#CCCCFFF"alink="#CCCCFFF"> <script language="JavaScript"> <!-- preloadimages('logo_jpg','pro_p.gif','pub_p.gif', 'mkt_p.gif', 'crs_p.gif','res_p.gof','who_p.gif','pro_w.gif', 'pub_w.gif', 'mkt_w.gif','crs_w.gif','res_w.gif','who_w.gif'); //--> </script> <table border="0"cellpadding="0"cellspacing="0"> <tr> <td width="top" align="left"> <table border="0"cellpadding="0"cellspacing="0"width="125"> <tr><td> <a href="index.htm"target="_top"onMouseOver="displaymsg('emlyv.com home');return true" onMouseOut="displaymsg('');return true"> <img src="logo.jpg"width="92"height="18"border="0"></a> </tr> </td></tr> </table> </td> <td valign="center" align="right"> <table border="0" cellpadding="0"cellspacing="0"width="486"> <tr><!--show row,height 1.--> <td><img src="shim.gif"width="81"height="1"border="0"></td> <td><img src="shim.gif"width="6"height="1"border="0"></td> <td><img src="shim.gif"width="81"height="1"border="0"></td> <td><img src="shim.gif"width="6"height="1"border="0"></td> <td><img src="shim.gif"width="72"height="1"border="0"></td> <td><img src="shim.gif"width="4"height="1"border="0"></td> <td><img src="shim.gif"width="67"height="1"border="0"></td> <td><img src="shim.gif"width="7"height="1"border="0"></td> <td><img src="shim.gif"width="65"height="1"border="0"></td> <td><img src="shim.gif"width="6"height="1"border="0"></td> <td><img src="shim.gif"width="89"height="1"border="0"></td> <td><img src="shim.gif"width="2"height="1"border="0"></td> <td><img src="shim.gif"width="1"height="1"border="0"></td> </tr> <tr><!--row1--> <td><a href="pro.htm"target="_top" onMouseOut="swap('promo_pic','pro_w.gif'); displaymsg('');return true" onMouseOver="swap('promo_pic','pro_p.gif');displaymsg('promote your writing online');return true"><img name="promo_pic"src="pro_w.gif" width="81" height="12" border="0"></a></td> <td><img name="r1_c02"src="r1_c02.gif"width="6" height="12"border="0"></td>
<td><a href="pub.htm"target="_top" onMouseOut="swap('pub_pic','pub_w.gif'); displaymsg('');return true" onMouseOver="swap('pub_pic','pub_p.gif');displaymsg('is electronic publishing right for you?');return true"><img name="pub_pic"src="pub_w.gif" width="81" height="12" border="0"></a></td> <td><img name="r1_c04"src="r1_c04.gif"width="6" height="12"border="0"></td>
<td><a href="mkt.htm"target="_top" onMouseOut="swap('mkt_pic','mkt_w.gif'); displaymsg('');return true" onMouseOver="swap('mkt_pic','mkt_p.gif');displaymsg('find paying online markets for your work');return true"><img name="mkt_pic"src="mkt_w.gif" width="72" height="12" border="0"></a></td> <td><img name="r1_c06"src="r1_c06.gif"width="4" height="12"border="0"></td> <td><a href="crs.htm"target="_top" onMouseOut="swap('course_pic','crs_w.gif'); displaymsg('');return true" onMouseOver="swap('course_pic','crs_p.gif');displaymsg('take an online writing course');return true"><img name="course_pic"src="crs_w.gif" width="67" height="12" border="0"></a></td> <td><img name="r1_c08"src="r1_c08.gif"width="7" height="12"border="0"></td>
<td><a href="res.htm"target="_top" onMouseOut="swap('res_pic','res_w.gif'); displaymsg('');return true" onMouseOver="swap('res_pic','res_p.gif');displaymsg('writing-related resources');return true"><img name="res_pic"src="res_w.gif" width="65" height="12" border="0"></a></td> <td><img name="r1_c10"src="r1_c10.gif"width="6" height="12"border="0"></td>
<td><a href="who.htm"target="_top" onMouseOut="swap('who_pic','who_w.gif'); displaymsg('');return true" onMouseOver="swap('who_pic','who_p.gif');displaymsg('who is emilyv?');return true"><img name="who_pic"src="who_w.gif" width="89" height="12" border="0"></a></td> <td><img name="r1_c12"src="r1_c12.gif"width="2" height="12"border="0"></td> <td><img src="shim.gif"width="1"height="12" border="0"></td> </tr> </table> </html>
其中preloadimages这个函数可以不用吗? 还有swap这个函数的具体用途是? 望指点.