圖片響應鼠標變換 - 中國WEB開發者網絡 (http://www.webasp.net) -- 網頁特效 (http://www.webasp.net/javascript/) --- 圖片響應鼠標變換 (http://www.webasp.net/javascript/1/245.htm) |
| -- 發佈日期: 2004-06-30 |
| <!-- 網頁特效代碼由[中國WEB開發者網絡:http://www.ChinaWebDev.com]提供! --> <!-- 要實現此效果需要 2 個步驟: --> <!-- 第 1 步: --> <!-- 把<BODY>中的屬性代碼改為: --> <BODY bgcolor="#fef4d9"> <!-- 第 2 步: --> <!-- 把下面的代碼加到<BODY></BODY>區域中: --> <center> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var rand1 = 0; var useRand = 0; images = new Array; images[1] = new Image(); images[1].src = "images/webasp.net.1.jpg"; images[2] = new Image(); images[2].src = "images/webasp.net.2.jpg"; images[3] = new Image(); images[3].src = "images/webasp.net.3.jpg"; images[4] = new Image(); images[4].src = "images/webasp.net.4.jpg"; function swapPic() { var imgnum = images.length - 1; do { var randnum = Math.random(); rand1 = Math.round((imgnum - 1) * randnum) + 1; } while (rand1 == useRand); useRand = rand1; document.randimg.src = images[useRand].src; } // End --> </script> <a onClick="swapPic();"><img name="randimg" src="http://www.webasp.net/js/images/webasp.net.1.jpg"></a><br> <font face="Verdana" size="-2">click image to change</font> </center> |
| webasp.net |