实用的小代码4--点击图片才能看到连接
说明: 第一步:把如下代码加入<head>区域中 <SCRIPT language="JavaScript"> <!-- function MM_showHideLayers() { //v2.0 var i, visStr, args, theObj; args = MM_showHideLayers.arguments; for (i=0; i<(args.length-2); i+=3) { //with arg triples (objNS,objIE,visStr) visStr = args[i+2]; if (navigator.appName == 'Netscape' && document.layers != null) { theObj = eval(args[i]); if (theObj) theObj.visibility = visStr; } else if (document.all != null) { //IE if (visStr == 'show') visStr = 'visible'; //convert vals if (visStr == 'hide') visStr = 'hidden'; theObj = eval(args[i+1]); if (theObj) theObj.style.visibility = visStr; } } }
function MM_preloadImages() { //v2.0 if (document.images) { var imgFiles = MM_preloadImages.arguments; if (document.preloadArray==null) document.preloadArray = new Array(); var i = document.preloadArray.length; with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){ preloadArray[i] = new Image; preloadArray[i++].src = imgFiles[j]; } } } //-->
</SCRIPT>
第二步:在<body>区中加入如下代码 <div id="Layer1" style="position:absolute; left:240px; top:175px; width:306px; height:63px; z-index:1; visibility: hidden"><a href="http://www.codefans.com/logo/slogo.gif"><font color=red size="2" >欢迎进入!</font></a></font></div> <div id="Layer2" style="position:absolute; left:280px; top:237px; width:147px; height:82px; z-index:2; visibility: visible"> <p align="center"><a href="http://www.codefans.com" target="_blank"> <img SRC="tb3.jpg" border="0" onMouseDown="MM_showHideLayers('document.layers[\'Layer1\']','document.all[\'Layer1\']','show')"></a></font><br> </p> </div>
第三步:把<body>区中内容改为: <body bgcolor="#fef4d9" onLoad="MM_preloadImages()">
|