175、图片响应鼠标变换

175、图片响应鼠标变换

脚本说明:

 

第一步:把如下代码加入<body>区域中

 

<center>

 

<SCRIPT LANGUAGE="JavaScript">

 

<!-- Begin

 

var rand1 = 0;

 

var useRand = 0;

 

 

 

images = new Array;

 

images[1] = new Image();

 

images[1].src = "image1.gif";

 

images[2] = new Image();

 

images[2].src = "image2.gif";

 

images[3] = new Image();

 

images[3].src = "image3.gif";

 

images[4] = new Image();

 

images[4].src = "image4.gif";

 

 

 

 

 

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="image1.gif"></a><br>

 

<font face="Verdana" size="-2">click image to change</font>

 

</center>

 

 

 

第二步:<body>区域中内容改为:

 

<body bgcolor="#fef4d9" OnLoad="swapPic()">

 

 

Write a comment

Comments: 0