欢迎来访571免费空间,希望可以对您有所帮助!

网站地图帮助中心

DEDECMS广告轮换代码(幻灯效果)

来源:571免费资源 作者:571free.com 人气: 发布时间:2010-06-13
摘要:作用 : 广告轮换 效果 : 本站(571免费空间: http://www.571free.com/ )头部中间图片广告 优势 : 每5秒切换一次,一个广告位展现N个广告 大大提高了广告位

作用

广告轮换

效果

本站(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);
}

欢迎转载,转载请注明原文网址:http://www.571free.com/zhimeng/1269/

随机免费资源

Copyright © 2009-2016 571FREE. 571免费资源 版权所有 豫ICP备15002996号

Theme by 571FREE.COM! X3 致力于做有用的网站   

请勿发布违反中华人民共和国法律法规的言论.