随机数重复了^_^<script language="javascript">
<!--
// JavaScript Document
window.onload=initLink;var adImages=new Array("images/1.jpg","images/2.jpg","images/3.jpg");
var adLinks=new Array("google.com","baidu.com","gougou.com");
function initLink(){
var imgParent=document.getElementById("img2").parentNode;
if(imgParent.tagName=="A"){
imgParent.onclick=NewLocation;
}
nextRotate();
}
var ch=0
function nextRotate(){
var adNum=Math.floor((Math.random()*adImages.length));
var img=document.getElementById("img2");
img.src=adImages[adNum];
setTimeout("nextRotate()",1000);
ch++
document.getElementById("ttt").innerHTML=ch+":"+adNum
}
function NewLocation(){
document.location.href="http://www."+adLinks[0];
return false;
}
//-->
</script>
<a href="texthtml.html"><img src="img2.jpg" alt="img2" id="img2"/></a>
<br>
<span id=ttt></span>
random()--伪随机,有相邻重复
<!--
// JavaScript Document
window.onload=initLink;var adImages=new Array("images/1.jpg","images/2.jpg","images/3.jpg");
var adLinks=new Array("google.com","baidu.com","gougou.com");
function initLink(){
var imgParent=document.getElementById("img2").parentNode;
if(imgParent.tagName=="A"){
imgParent.onclick=NewLocation;
}
nextRotate();
}
var ch=0
function nextRotate(){
var adNum=Math.floor((Math.random()*adImages.length));
var img=document.getElementById("img2");
img.src=adImages[adNum];
setTimeout("nextRotate()",1000);
ch++
document.getElementById("ttt").innerHTML=ch+":"+adNum
}
function NewLocation(){
document.location.href="http://www."+adLinks[0];
return false;
}
//-->
</script>
<a href="texthtml.html"><img src="img2.jpg" alt="img2" id="img2"/></a>
<br>
<span id=ttt></span>
random()--伪随机,有相邻重复
呵呵.小弟学习了..
结贴了.