javascript|廣告
示範效果:http://www.webjx.com/htmldata/2005-11-26/test.html
<script LANGUAGE="javascript">
<!--
var cpAD=new Array();
var cpADlink=new Array();
var cpADmsg=new Array();
//定義了5個數組
var adNum=5;
var coll=0;
//ad/1.html 那時你連結的廣告地址
cpAD[0]="banners/mba.gif";
cpADlink[0]="ad/1.html";
cpADmsg[0]="1";
cpAD[1]="banners/google.gif";
cpADlink[1]="ad/2.html"
cpADmsg[1]="2";
cpAD[2]="banners/2005.gif";
cpADlink[2]="ad/3.html";
cpADmsg[2]="3";
cpAD[3]="banners/cz8y.gif";
cpADlink[3]="ad/4.html";
cpADmsg[3]="4";
cpAD[4]="banners/JG_YUEDU.gif";
cpADlink[4]="ad/5.html";
cpADmsg[4]="5";
var preloadedimages=new Array();
for (i=1;i<cpAD.length;i++){
preloadedimages[i]=new Image();
preloadedimages[i].src=cpAD[i];
}
//跳轉的URL地址
function jump2url()
{
jumpUrl=cpADlink[adNum];
jumpTarget='_blank';
if (jumpUrl != '')
{
if (jumpTarget != '')
window.open(jumpUrl,jumpTarget);
else location.href=jumpUrl;
}
}
//圖片變化的函數
function changeimg(n)
{
adNum=n;
switch(adNum)
{
case 0:
{
window.img1.src="/UploadPic/2007-7/20077717158750.gif";
window.img2.src="/UploadPic/2007-7/20077717159630.gif";
window.img3.src="/UploadPic/2007-7/20077717159771.gif";
window.img4.src="4.gif";
window.img5.src="/UploadPic/2007-7/20077717159962.gif";
break;
}
case 1:
{
window.img1.src="/UploadPic/2007-7/20077717159287.gif";
window.img2.src="/UploadPic/2007-7/20077717159359.gif";
window.img3.src="/UploadPic/2007-7/20077717159771.gif";
window.img4.src="4.gif";
window.img5.src="/UploadPic/2007-7/20077717159962.gif";
break;
}
case 2:
{
window.img1.src="/UploadPic/2007-7/20077717159287.gif";
window.img2.src="/UploadPic/2007-7/20077717159630.gif";
window.img3.src="/UploadPic/2007-7/20077717159990.gif";
window.img4.src="4.gif";
window.img5.src="/UploadPic/2007-7/20077717159962.gif";
break;
}
case 3:
{
window.img1.src="/UploadPic/2007-7/20077717159287.gif";
window.img2.src="/UploadPic/2007-7/20077717159630.gif";
window.img3.src="/UploadPic/2007-7/20077717159771.gif";
window.img4.src="/UploadPic/2007-7/20077717159187.gif";
window.img5.src="/UploadPic/2007-7/20077717159962.gif";
break;
}
case 4:
{
window.img1.src="/UploadPic/2007-7/20077717159287.gif";
window.img2.src="/UploadPic/2007-7/20077717159630.gif";
window.img3.src="/UploadPic/2007-7/20077717159771.gif";
window.img4.src="4.gif";
window.img5.src="/UploadPic/2007-7/20077717159913.gif";
break;
}
}
window.clearInterval(theTimer);
adNum=adNum-1;
nextAd();
}
//當點擊時直接跳轉
function nextAd(){
coll++;
if(coll>1)
{
switch(adNum+1)
{
case 5:
{
window.img1.src="/UploadPic/2007-7/20077717158750.gif";
window.img2.src="/UploadPic/2007-7/20077717159630.gif";
window.img3.src="/UploadPic/2007-7/20077717159771.gif";
window.img4.src="4.gif";
window.img5.src="/UploadPic/2007-7/20077717159962.gif";
break;
}
case 1:
{
window.img1.src="/UploadPic/2007-7/20077717159287.gif";
window.img2.src="/UploadPic/2007-7/20077717159359.gif";
window.img3.src="/UploadPic/2007-7/20077717159771.gif";
window.img4.src="4.gif";
window.img5.src="/UploadPic/2007-7/20077717159962.gif";
break;
}
case 2:
{
window.img1.src="/UploadPic/2007-7/20077717159287.gif";
window.img2.src="/UploadPic/2007-7/20077717159630.gif";
window.img3.src="/UploadPic/2007-7/20077717159990.gif";
window.img4.src="4.gif";
window.img5.src="/UploadPic/2007-7/20077717159962.gif";
break;
}
case 3:
{
window.img1.src="/UploadPic/2007-7/20077717159287.gif";
window.img2.src="/UploadPic/2007-7/20077717159630.gif";
window.img3.src="/UploadPic/2007-7/20077717159771.gif";
window.img4.src="/UploadPic/2007-7/20077717159187.gif";
window.img5.src="/UploadPic/2007-7/20077717159962.gif";
break;
}
case 4:
{
window.img1.src="/UploadPic/2007-7/20077717159287.gif";
window.img2.src="/UploadPic/2007-7/20077717159630.gif";
window.img3.src="/UploadPic/2007-7/20077717159771.gif";
window.img4.src="4.gif";
window.img5.src="/UploadPic/2007-7/20077717159913.gif";
break;
}
}
}
if(adNum<cpAD.length-1)adNum++ ;
else adNum=0;
setTransition();
document.images.cpADrush.src=cpAD[adNum];
playTransition();
displayStatusMsg();
//定義了輪換時間 5s
theTimer=setTimeout("nextAd()", 5000);
}
function setTransition(){
if (document.all){
cpADrush.filters.revealTrans.Transition=23;
cpADrush.filters.revealTrans.apply();
}
}
function playTransition(){
if (document.all)
cpADrush.filters.revealTrans.play()
}
function displayStatusMsg() {
status=cpADmsg[adNum];
document.returnValue = true;
}
//結束
// -->
</script>
<table height="148" cellspacing="0" cellpadding="0">
<tr>
<td> <a href="javascript:jump2url()"> <img style="FILTER: revealTrans(duration=2,transition=23)" height="150" src width="575" border="0" name="cpADrush"></a></td>
<script language="JavaScript">nextAd()</script>
</tr>
<tr>
<td>
<table width="575" name="T1" id="T1" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="right"><img src="/UploadPic/2007-7/20077717159523.gif" width="178" height="16"></td>
<td width="20"><a href="#" ><img name="Image2" id="img1" border="0" src="/UploadPic/2007-7/20077717159287.gif" width="20" height="16" ></a></td>
<td width="20"><a href="#" ><img name="Image3" id="img2" border="0" src="/UploadPic/2007-7/20077717159630.gif" width="20" height="16" ></a></td>
<td width="20"><a href="#" ><img name="Image4" id="img3" border="0" src="/UploadPic/2007-7/20077717159771.gif" width="20" height="16" ></a></td>
<td width="20"><a href="#" ><img name="Image5" id="img4" border="0" src="4.gif" width="20" height="16" ></a></td>
<td width="20"><a href="#" ><img name="Image6" id="img5" border="0" src="/UploadPic/2007-7/20077717159962.gif" width="20" height="16" ></a></td>
</tr>
</table>
</td>
</tr>
</table>