位置:71code站长站站长学习网站开发JavaS、VbS → 轮换广告代码加演示

轮换广告代码加演示

减小字体 增大字体 作者:Ahaoz.CoM  来源:本站整理  发布时间:2006-4-25 9:25:56
点击这里,查看预览效果......

<script LANGUAGE="javascript">
<!--
var cpAD=new Array();
var cpADlink=new Array();
var cpADmsg=new Array();
var adNum=5; //定义了5个数组
var coll=0;

cpAD[0]="banners/mba.gif"; //链接图片
cpADlink[0]="http://www.5dm.cn/"; //链接URL
cpADmsg[0]="mba.gif";//状态栏提示信息

cpAD[1]="banners/google.gif";
cpADlink[1]="http://www.5dm.cn/"
cpADmsg[1]="google.gif";

cpAD[2]="banners/2005.gif";
cpADlink[2]="http://www.5dm.cn/";
cpADmsg[2]="2005.gif";

cpAD[3]="banners/cz8y.gif";
cpADlink[3]="http://www.5dm.cn/";
cpADmsg[3]="cz8y.gif";

cpAD[4]="banners/JG_YUEDU.gif";
cpADlink[4]="http://www.5dm.cn/";
cpADmsg[4]="JG_YUEDU.gif";

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="images/1-2.gif";
window.img2.src="http://www.5dm.cn/images/2.gif";
window.img3.src="http://www.5dm.cn/images/3.gif";
window.img4.src="http://www.5dm.cn/images/4.gif";
window.img5.src="http://www.5dm.cn/images/5.gif";
break;
}
case 1:
{
window.img1.src="http://www.5dm.cn/images/1.gif";
window.img2.src="images/2-2.gif";
window.img3.src="http://www.5dm.cn/images/3.gif";
window.img4.src="http://www.5dm.cn/images/4.gif";
window.img5.src="http://www.5dm.cn/images/5.gif";
break;
}
case 2:
{
window.img1.src="http://www.5dm.cn/images/1.gif";
window.img2.src="http://www.5dm.cn/images/2.gif";
window.img3.src="images/3-2.gif";
window.img4.src="http://www.5dm.cn/images/4.gif";
window.img5.src="http://www.5dm.cn/images/5.gif";
break;
}
case 3:
{
window.img1.src="http://www.5dm.cn/images/1.gif";
window.img2.src="http://www.5dm.cn/images/2.gif";
window.img3.src="http://www.5dm.cn/images/3.gif";
window.img4.src="images/4-2.gif";
window.img5.src="http://www.5dm.cn/images/5.gif";
break;
}
case 4:
{
window.img1.src="http://www.5dm.cn/images/1.gif";
window.img2.src="http://www.5dm.cn/images/2.gif";
window.img3.src="http://www.5dm.cn/images/3.gif";
window.img4.src="http://www.5dm.cn/images/4.gif";
window.img5.src="images/5-2.gif";
break;
}
}
window.clearInterval(theTimer);
adNum=adNum-1;
nextAd();
}
//当点击时直接跳转
function nextAd(){
coll++;
if(coll>1)
{
switch(adNum+1)
{
case 5:
{
window.img1.src="images/1-2.gif";
window.img2.src="http://www.5dm.cn/images/2.gif";
window.img3.src="http://www.5dm.cn/images/3.gif";
window.img4.src="http://www.5dm.cn/images/4.gif";
window.img5.src="http://www.5dm.cn/images/5.gif";
break;
}
case 1:
{
window.img1.src="http://www.5dm.cn/images/1.gif";
window.img2.src="images/2-2.gif";
window.img3.src="http://www.5dm.cn/images/3.gif";
window.img4.src="http://www.5dm.cn/images/4.gif";
window.img5.src="http://www.5dm.cn/images/5.gif";
break;
}
case 2:
{
window.img1.src="http://www.5dm.cn/images/1.gif";
window.img2.src="http://www.5dm.cn/images/2.gif";
window.img3.src="images/3-2.gif";
window.img4.src="http://www.5dm.cn/images/4.gif";
window.img5.src="http://www.5dm.cn/images/5.gif";
break;
}
case 3:
{
window.img1.src="http://www.5dm.cn/images/1.gif";
window.img2.src="http://www.5dm.cn/images/2.gif";
window.img3.src="http://www.5dm.cn/images/3.gif";
window.img4.src="images/4-2.gif";
window.img5.src="http://www.5dm.cn/images/5.gif";
break;
}
case 4:
{
window.img1.src="http://www.5dm.cn/images/1.gif";
window.img2.src="http://www.5dm.cn/images/2.gif";
window.img3.src="http://www.5dm.cn/images/3.gif";
window.img4.src="http://www.5dm.cn/images/4.gif";
window.img5.src="images/5-2.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="http://www.5dm.cn/images/dh_bg.gif" width="178" height="16"></td>
<td width="20"><a href="javascript:;" ><img name="Image2" id="img1" border="0" src="http://www.5dm.cn/images/1.gif" width="20" height="16" ></a></td>
<td width="20"><a href="javascript:;" ><img name="Image3" id="img2" border="0" src="http://www.5dm.cn/images/2.gif" width="20" height="16" ></a></td>
<td width="20"><a href="javascript:;" ><img name="Image4" id="img3" border="0" src="http://www.5dm.cn/images/3.gif" width="20" height="16" ></a></td>
<td width="20"><a href="javascript:;" ><i

[1] [2]  下一页