Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

展示二个或替换一个更多的无限循环的广告 (480 x 60)

[复制链接]
hufanyun 发表于 2005-10-19 15:35:13 | 显示全部楼层 |阅读模式
在<body>中加入onLoad="initVar(); moveBanner()"

以下代码加入<head>区域或者想调用的地方加:
  1. <style type="text/css">
  2. <!--
  3. #addbox {
  4.   position: relative;
  5.   width: 500px;
  6.   height: 70 px;
  7.   clip: rect(0px, 500px, 0px, 70px);
  8.   overflow: hidden;
  9. }
  10. #banner1 {
  11.   position: relative;
  12.   width: 480px;
  13.   height: 60px;
  14.   left: 0;
  15.   top: 5px;
  16. }
  17. #banner2 {
  18.   position: relative;
  19.   width: 480px;
  20.   height: 60px;
  21.   left: 500px;
  22.   top: -55px !important;
  23.   top:-58px;
  24. }
  25. -->
  26. </style>

  27. <script type="text/javascript">
  28. <!--


  29. var displayTime, speed, wait, banner1, banner2, link1, link2, bannerIndex, bannerLocations, bannerURLs;

  30. function initVar() {
  31.   displayTime = 10; // The amount of time each banner will be displayed in seconds.
  32.   speed = 5; // The speed at which the banners is moved (1 - 10, anything above 5 is not recommended).
  33.   wait = true;

  34.   banner1 = document.getElementById("banner1");
  35.   banner2 = document.getElementById("banner2");
  36.   link1 = document.getElementById("link1");
  37.   link2 = document.getElementById("link2");

  38.   banner1 = document.getElementById("banner1");
  39.   banner2 = document.getElementById("banner2");

  40.   banner1.style.left = 0;
  41.   banner2.style.left = 500;

  42.   bannerIndex = 1;

  43.   /* Important: In order for this script to work properly, please make sure that the banner graphic and the
  44.   URL associated with it have the same index in both, the bannerLocations and bannerURLs arrays.
  45.   Duplicate URLs are permitted. */

  46.   // Enter the location of the banner graphics in the array below.
  47.   bannerLocations = new Array("www.twinsworld.org/jsimg/pic1.jpg","www.twinsworld.org/jsimg/pic2.jpg","www.twinsworld.org/jsimg/pic3.jpg","www.twinsworld.org/jsimg/pic4.jpg","www.twinsworld.org/jsimg/pic5.jpg");

  48.   // Enter the URL's to which the banners will link to in the array below.
  49.   bannerURLs = new Array("http://www.twinsworld.org","http://www.twinsworld.org","http://www.twinsworld.org","http://www.twinsworld.org","http://www.twinsworld.org");
  50. }
  51. function moveBanner(){
  52.   if(!wait){
  53.     banner1.style.left = parseInt(banner1.style.left) -  (speed * 5);
  54.     banner2.style.left = parseInt(banner2.style.left) - (speed * 5);
  55.     if(parseInt(banner1.style.left) <= -500){
  56.       banner1.style.left = 500;
  57.       bannerIndex = (bannerIndex < (bannerLocations.length - 1)) ? ++bannerIndex :0;
  58.       banner1.src = bannerLocations[bannerIndex];
  59.       link1.href = bannerURLs[bannerIndex];
  60.       wait = true;
  61.     }
  62.     if(parseInt(banner2.style.left) <= -500){
  63.       banner2.style.left = 500;
  64.       bannerIndex = (bannerIndex < (bannerLocations.length - 1)) ? ++bannerIndex :0;
  65.       banner2.src = bannerLocations[bannerIndex];
  66.       link2.href = bannerURLs[bannerIndex];
  67.       wait = true;
  68.     }

  69.     setTimeout("moveBanner()",100);
  70.   } else {
  71.       wait = false;
  72.       setTimeout("moveBanner()", displayTime * 1000);
  73.   }
  74. }
  75. -->
  76. </script>
复制代码



以下代码加入想实现的区域:

  1. <div align="center">
  2. <div name="addbox" id="addbox">
  3. <a name="link1" id="link1" href="www.twinsworld.org"><img border="0" name="banner1"

  4. id="banner1" src="www.twinsworld.org/jsimg/pic1.jpg"></a>
  5. <a name="link2" id="link2" href="www.twinsworld.org"><img border="0" name="banner2"

  6. id="banner2" src="www.twinsworld.org/jsimg/pic2.jpg"></a>
  7. </div></div>
复制代码

评分

1

查看全部评分

okkko 发表于 2005-10-19 15:41:59 | 显示全部楼层
好东西!顶起来
回复

使用道具 举报

 楼主| hufanyun 发表于 2005-10-19 16:11:02 | 显示全部楼层
原帖由 okkko 于 2005-10-19 15:41 发表
好东西!顶起来

顶。。
回复

使用道具 举报

5025488.net 发表于 2005-10-19 16:52:41 | 显示全部楼层
好,支持!
回复

使用道具 举报

 楼主| hufanyun 发表于 2005-10-20 09:47:43 | 显示全部楼层
原帖由 西门不败 于 2005-10-19 16:52 发表
好,支持!

参考这个可以想到很多
回复

使用道具 举报

ygm007 发表于 2005-10-20 14:31:02 | 显示全部楼层
感谢楼主,这样的东西就要顶~~~~~~~~
回复

使用道具 举报

jimmyjimmyqqq 发表于 2005-10-20 15:32:27 | 显示全部楼层
Ding ..........Thx H moD
回复

使用道具 举报

『狂』 发表于 2005-10-20 22:03:08 | 显示全部楼层
<body>
是甚麼來的
回复

使用道具 举报

linsie 发表于 2005-12-13 12:15:57 | 显示全部楼层
发先你发的东西都很爽
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-21 21:58 , Processed in 0.025808 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表