日期:2014-05-16 浏览次数:20431 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> Change photos</title>
<script type="text/javascript">
var myImages=new Array("1.gif","2.gif","3.gif","4.gif");
function changeImage (imgNumber) {
var imgClicked=document.images[imgNumber];
var newImgNumber=Math.round(Math.random()*3);
while (imgClicked.src.indexOf(myImages[newImgNumber])!=-1) {
newImgNumber=Math.round(Math.random()*3);
}
imgClicked.src=myImages[newImgNumber];
return false;
}
</script>
</head>
<body>
<img name="img1" src="1.gif" boder="0" onclick="changeImage(1)"/>
<img name="img2" src="2.gif" boder="0" onclick="changeImage(2)"/>
</body>
</html>