87,904
社区成员
发帖
与我相关
我的任务
分享
// JavaScript Document
window.onload=initLink;
var adImages=new Array("img2.jpg","img22a.jpg","img22b.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();
}
function nextRotate()
{
var adNum=Math.floor((Math.random()*adImages.length));
var img=document.getElementById("img2");
img.src=adImages[adNum];
setTimeout("nextRotate()",1000);
}
function NewLocation()
{
document.location.href="http://www."+adLinks[0];
return false;
}
<a href="texthtml.html"><img src="img2.jpg" alt="img2" id="img2"/></a>
<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>