全国400电话网上服务平台
强大号码库资源任选,方便,快捷,快速开通。
咨询热线:400-1100-266
DEDECMS广告轮换代码(幻灯效果)
POST TIME:2017-12-29 23:06
作用:
广告轮换
效果:
本站(571免费空间:http://www.571free.com/)头部中间图片广告
优势:
每5秒切换一次,一个广告位展现N个广告
大大提高了广告位置的利用率
且广告处于动态方式,实时更换,更吸引人。
劣势:
网页需要多加载3个图片,不过对于GIF格式的图片,实在说不上是大,对于网页速度的影响还是有限的
代码展现:
<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/ad/1.gif";
cpADlink[0]="http://count.chanet.com.cn/click.cgi?a=294504&d=131883&u=&e=";
cpADmsg[0]="1";
cpAD[1]="/banners/ad/2.gif";
cpADlink[1]="http://count.chanet.com.cn/click.cgi?a=294504&d=18290&u=&e="
cpADmsg[1]="2";
cpAD[2]="/banners/ad/3.gif";
cpADlink[2]="http://count.chanet.com.cn/click.cgi?a=294504&d=37894&u=&e=";
cpADmsg[2]="3";
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="banners/1-2.gif";
window.img2.src="banners/2.gif";
window.img3.src="banners/3.gif";
window.img4.src="banners/4.gif";
window.img5.src="banners/5.gif";
break;
}
case 1:
{
window.img1.src="banners/1.gif";
window.img2.src="banners/2-2.gif";
window.img3.src="banners/3.gif";
window.img4.src="banners/4.gif";
window.img5.src="banners/5.gif";
break;
}
case 2:
{
window.img1.src="banners/1.gif";
window.img2.src="banners/2.gif";
window.img3.src="banners/3-2.gif";
window.img4.src="banners/4.gif";
window.img5.src="banners/5.gif";
break;
}
case 3:
{
window.img1.src="banners/1.gif";
window.img2.src="banners/2.gif";
window.img3.src="banners/3.gif";
window.img4.src="banners/4-2.gif";
window.img5.src="banners/5.gif";
break;
}
case 4:
{
window.img1.src="banners/1.gif";
window.img2.src="banners/2.gif";
window.img3.src="banners/3.gif";
window.img4.src="banners/4.gif";
window.img5.src="banners/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="banners/1-2.gif";
window.img2.src="banners/2.gif";
window.img3.src="banners/3.gif";
window.img4.src="banners/4.gif";
window.img5.src="banners/5.gif";
break;
}
case 1:
{
window.img1.src="banners/1.gif";
window.img2.src="banners/2-2.gif";
window.img3.src="banners/3.gif";
window.img4.src="banners/4.gif";
window.img5.src="banners/5.gif";
break;
}
case 2:
{
window.img1.src="banners/1.gif";
window.img2.src="banners/2.gif";
window.img3.src="banners/3-2.gif";
window.img4.src="banners/4.gif";
window.img5.src="banners/5.gif";
break;
}
case 3:
{
window.img1.src="banners/1.gif";
window.img2.src="banners/2.gif";
window.img3.src="banners/3.gif";
window.img4.src="banners/4-2.gif";
window.img5.src="banners/5.gif";
break;
}
case 4:
{
window.img1.src="banners/1.gif";
window.img2.src="banners/2.gif";
window.img3.src="banners/3.gif";
window.img4.src="banners/4.gif";
window.img5.src="banners/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);
}
|
Copyright © 2003-2016
时间:9:00-21:00 (节假日不休)
版权所有:巨人网络(扬州)科技有限公司
总部地址:江苏省信息产业基地11号楼四层
《增值电信业务经营许可证》 苏B2-20120278