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

 找回密码
 立即注册
搜索

[分享] 在平湖中实现对联广告

[复制链接]
MYSUNCK 发表于 2009-7-8 18:52:07 | 显示全部楼层 |阅读模式
在平湖中实现对联广告,这个很简答。
在index.php.html找到
  1. <script type="text/javascript" src="{S_URL}/include/js/weather.js"></script>
复制代码
下面添加
  1. <script type="text/javascript" src="{S_URL}/templates/$_SCONFIG[template]/js/duilian.js"></SCRIPT>
复制代码
这是JS的代码,到记事本里另存为duilian.js放到你平湖目录里js文件夹里
  1. var delta=0.015;
  2. var collection;
  3. var closeB=false;
  4. function floaters() {
  5.  this.items = [];
  6.  this.addItem = function(id,x,y,content)
  7.    {
  8.    document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
  9.   
  10.    var newItem  = {};
  11.    newItem.object  = document.getElementById(id);
  12.    newItem.x  = x;
  13.    newItem.y  = y;

  14.    this.items[this.items.length] = newItem;
  15.    }
  16.  this.play = function()
  17.    {
  18.    collection  = this.items
  19.    setInterval('play()',30);
  20.    }
  21.  }
  22.  function play()
  23.  {
  24.   if(screen.width<=800 || closeB)
  25.   {
  26.   for(var i=0;i<collection.length;i++)
  27.   {
  28.    collection[i].object.style.display = 'none';
  29.   }
  30.   return;
  31.   }
  32.   for(var i=0;i<collection.length;i++)
  33.   {
  34.   var followObj = collection[i].object;
  35.   var followObj_x = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
  36.   var followObj_y = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);

  37.   if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
  38.    var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
  39.    dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
  40.    followObj.style.left=followObj.offsetLeft+dx;
  41.    }

  42.   if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) {
  43.    var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta;
  44.    dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
  45.    followObj.style.top=followObj.offsetTop+dy;
  46.    }
  47.   followObj.style.display = '';
  48.   }
  49.  }
  50.  function closeBanner()
  51.  {
  52.   closeB=true;
  53.   return;
  54.  }

  55. var theFloaters = new floaters();
  56. //
  57. theFloaters.addItem('followDiv1','document.body.clientWidth-100',0,'<iframe id="baiduSpFrame" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no" width="80" height="80" src="http://spcode.baidu.com/spcode/spstyle/style1301.jsp?tn=mysunck_sp&ctn=0&styleid=1301"></iframe>');
  58. theFloaters.addItem('followDiv2',0,0,'<iframe id="baiduSpFrame" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no" width="80" height="80" src="http://spcode.baidu.com/spcode/spstyle/style1301.jsp?tn=mysunck_sp&ctn=0&styleid=1301"></iframe>');
  59. theFloaters.play();

复制代码
我这里引用的是百度联盟的页面,所以用了ifame标签
如果想用图片
分别把
  1. <iframe id="baiduSpFrame" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no" width="80" height="80" src="http://spcode.baidu.com/spcode/spstyle/style1301.jsp?tn=mysunck_sp&ctn=0&styleid=1301"></iframe>
复制代码
改成
  1. <a onClick="closeBanner();" href=连接><img src=图片地址 width=宽 height=高 border=0></a>
复制代码
就可以了
回复

使用道具 举报

五元超市 发表于 2009-7-8 23:53:17 | 显示全部楼层
谢谢分享。











DZ、SS、UCHOME相关问题解决
加QQ 747983834
回复

使用道具 举报

wktxw 发表于 2009-7-9 03:40:15 | 显示全部楼层
((em:13))((em:13))
回复

使用道具 举报

々脚印 发表于 2009-7-11 22:17:06 | 显示全部楼层
不错哦。。。。。试试先!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-10-16 05:27 , Processed in 0.121111 second(s), 14 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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