• [织梦吧]唯一域名:www.dedecms8.com,织梦DedeCMS学习平台.

当前位置: > DedeCMS教程 > DedeCMS安装使用 >

让你的dedecms实现多个广告轮播滚动显示

来源: www.dedecms8.com 编辑:织梦吧 时间:2010-08-23点击:

作用:
轮换
优势:
每5秒切换一次,一个广告位展现N个广告
大大提高了广告位置的利用率
且广告处于动态方式,实时更换,更吸引人。
劣势:
网页需要多加载3个图片,不过对于GIF格式的图片,实在说不上是大,对于网页速度的影响还是有限的
代码展现:
 


  1. <script LANGUAGE="javascript">
  2. <!--
  3. var cpAD=new Array();
  4. var cpADlink=new Array();
  5. var cpADmsg=new Array();
  6. //定义了5个数组
  7. var adNum=5;
  8. var coll=0;
  9. //ad/1.html 那时你链接的广告地址
  10. cpAD[0]="/banners/ad/1.gif";
  11. cpADlink[0]="http://count.chanet.com.cn/click.cgi?a=294504&d=131883&u=&e=";
  12. cpADmsg[0]="1";
  13. cpAD[1]="/banners/ad/2.gif";
  14. cpADlink[1]="http://count.chanet.com.cn/click.cgi?a=294504&d=18290&u=&e="
  15. cpADmsg[1]="2";
  16. cpAD[2]="/banners/ad/3.gif";
  17. cpADlink[2]="http://count.chanet.com.cn/click.cgi?a=294504&d=37894&u=&e=";
  18. cpADmsg[2]="3";
  19. var preloadedimages=new Array();
  20. for (i=1;i<cpAD.length;i++){
  21. preloadedimages[i]=new Image();
  22. preloadedimages[i].src=cpAD[i];
  23. }
  24. //跳转的URL地址
  25. function jump2url()
  26. {
  27. jumpUrl=cpADlink[adNum];
  28. jumpTarget='_blank';
  29. if (jumpUrl != '')
  30. {
  31.         if (jumpTarget != '')
  32.                 window.open(jumpUrl,jumpTarget);
  33.         else location.href=jumpUrl;
  34.         }
  35. }
  36. //图片变化的函数
  37. function changeimg(n)
  38. {
  39.         adNum=n;
  40.         switch(adNum)
  41.         {
  42.         case 0:
  43.         {
  44.                 window.img1.src="banners/1-2.gif";
  45.                 window.img2.src="banners/2.gif";
  46.                 window.img3.src="banners/3.gif";
  47.                 window.img4.src="banners/4.gif";
  48.                 window.img5.src="banners/5.gif";
  49.                 break;
  50.         }
  51.         case 1:
  52.         {
  53.                 window.img1.src="banners/1.gif";
  54.                 window.img2.src="banners/2-2.gif";
  55.                 window.img3.src="banners/3.gif";
  56.                 window.img4.src="banners/4.gif";
  57.                 window.img5.src="banners/5.gif";
  58.                 break;
  59.         }
  60.         case 2:
  61.         {
  62.                 window.img1.src="banners/1.gif";
  63.                 window.img2.src="banners/2.gif";
  64.                 window.img3.src="banners/3-2.gif";
  65.                 window.img4.src="banners/4.gif";
  66.                 window.img5.src="banners/5.gif";
  67.                 break;
  68.         }
  69.                 case 3:
  70.         {
  71.                 window.img1.src="banners/1.gif";
  72.                 window.img2.src="banners/2.gif";
  73.                 window.img3.src="banners/3.gif";
  74.                 window.img4.src="banners/4-2.gif";
  75.                 window.img5.src="banners/5.gif";
  76.                 break;
  77.         }
  78.                 case 4:
  79.         {
  80.                 window.img1.src="banners/1.gif";
  81.                 window.img2.src="banners/2.gif";
  82.                 window.img3.src="banners/3.gif";
  83.                 window.img4.src="banners/4.gif";
  84.                 window.img5.src="banners/5-2.gif";
  85.                 break;
  86.         }
  87.         }
  88.         window.clearInterval(theTimer);
  89.         adNum=adNum-1;
  90.         nextAd();
  91. }

About D8

  • ©2014 织梦吧(d8) DedeCMS学习交流平台
  • 唯一网址 www.DedeCMS8.com 网站地图
  • 联系我们 1170734538@qq.com ,  QQ