当前位置: 首页 > article >正文

漂浮广告的代码汇总

第一种方法:

< div style = "" >< a href = " http://www.zzlanwang.cn/cpid.aspx?id=291 "  target = " _blank " >< img src = " img/logo.gif "  border = " 0 " ></ a ></ div >
  
< script >
  
var  x  =   50 ,y  =   60
  
var  xin  =   true , yin  =   true
  
var  step  =   1  
  
var  delay  =   10
  
var  obj = document.getElementById( " ad "
  
function  floatAD()  {
     
var L=T=0
     
var R= document.body.clientWidth-obj.offsetWidth
     
var B = document.body.clientHeight-obj.offsetHeight
     obj.style.left 
= x + document.body.scrollLeft
     obj.style.top 
= y + document.body.scrollTop
     x 
= x + step*(xin?1:-1)  
     
if (x < L) { xin = true; x = L} 
     
if (x > R){ xin = false; x = R} 
     y 
= y + step*(yin?1:-1
     
if (y < T) { yin = true; y = T } 
     
if (y > B) { yin = false; y = B } 
  }

  
var  itl =  setInterval( " floatAD() " , delay) 
 obj.onmouseover
= function () {clearInterval(itl)}  
 obj.onmouseout
= function () {itl=setInterval("floatAD()", delay)}
  
</ script >

 

第二种方法:

页面<body>下面加如如下一句话

<script language=JavaScript src="js/ad.js"></script>

js代码

 

var  delta = 0.08
 
var  collection;
 
function  floaters() {
  
this .items  =  [];
  
this .addItem  =   function (id,x,y,content)
      {
     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> ' );
     
     
var  newItem     =  {};
     newItem.object   
=  document.getElementById(id);
     newItem.x    
=  x;
     newItem.y    
=  y;

     
this .items[ this .items.length]   =  newItem;
      }
  
this .play  =   function ()
      {
     collection    
=   this .items
     setInterval(
' play() ' , 10 );
      }
  }
  
function  play()
  {

   
for ( var  i = 0 ;i < collection.length;i ++ )
   {
    
var  followObj   =  collection[i].object;
    
var  followObj_x   =  ( typeof (collection[i].x) == ' string ' ? eval(collection[i].x):collection[i].x);
    
var  followObj_y   =  ( typeof (collection[i].y) == ' string ' ? eval(collection[i].y):collection[i].y);

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

    
if (followObj.offsetTop != (document.body.scrollTop + followObj_y)) {
     
var  dy = (document.body.scrollTop + followObj_y - followObj.offsetTop) * delta;
     dy
= (dy > 0 ? 1 : - 1 ) * Math.ceil(Math.abs(dy));
     followObj.style.top
= followObj.offsetTop + dy;
     }
    followObj.style.display 
=   '' ;
   }
  } 
  
 
var  theFloaters   =   new  floaters();
 
// 右面
 theFloaters.addItem( ' followDiv1 ' , ' document.body.clientWidth-106 ' , 80 , ' <EMBED src=images/duilian.swf quality=high  WIDTH=100 HEIGHT=300 TYPE=application/x-shockwave-flash id=ad wmode=opaque></EMBED> ' );
 
// 左面
 theFloaters.addItem( ' followDiv2 ' , 6 , 80 , ' <EMBED src=images/duilian.swf quality=high  WIDTH=100 HEIGHT=300 TYPE=application/x-shockwave-flash id=ad wmode=opaque></EMBED> ' );
 theFloaters.play();
 
// 图片格式调用方法
//
<a href=http://www.makewing.com/lanren/ target=_blank><img src=images/ad_100x300.jpg border=0></a>
//
flash格式调用方法
//
<EMBED src=images/duilian.swf quality=high  WIDTH=100 HEIGHT=300 TYPE=application/x-shockwave-flash id=ad wmode=opaque></EMBED>
http://www.lryc.cn/news/2421074.html

相关文章:

  • Rational Rose 2007的详细安装步骤
  • BUUCTF题目Misc部分wp(持续更新)
  • InfluxDB源码解析
  • 使用ettercap进行ARP欺骗攻击实验(保姆级教程)
  • [转帖]手机报IN语
  • 【正点原子FPGA连载】第十三章 IP核之MMCM/PLL实验 -摘自【正点原子】领航者ZYNQ之FPGA开发指南_V2.0
  • 对数组名取地址
  • 从下列选项中选择正确的java表达式,java笔试常见的选择题
  • python automl_深度解析AutoML框架——H2O:小白也能使用的自动机器学习平台
  • 小迪安全 第12天:php开发-个人博客项目文章功能显示数据库操作数据接受
  • Spring Cloud Loadbalancer服务均衡负载器
  • 程序员需知的 58 个网站
  • 风云三国2.4问鼎天下修改作弊大全
  • Flickr为在照片中寻找朋友而添加了用户标签
  • 行健设计_【天财男女神季】张行健amp;程迪:十佳第一!=科研人的理性+统计人的责任+学霸情侣...
  • [Vulkan教程]绘制一个三角形/呈现/交换链(Swip chain)
  • vs2005快捷键大全
  • GUI Design Studio----如何创建交互式设计(二)
  • 如何用PS切图和输出网页?
  • 开源软件下载地址
  • 若非群玉山头见,会向瑶台月下逢
  • Vba菜鸟教程
  • 别盲从了,spring 解决循环依赖真的一定需要三级缓存吗?demo结合源码讲解三级缓存的真正目的,一级缓存singletonFactories的真正作用,看到文章最后让面试官眼前一亮
  • 华众 mysql_华众虚拟主机管理系统HZhost三大常见错误!
  • visual studio 2008 开发c++学习(一):参考网上材料
  • 网页中Flash如何下载?网页中Flash下载方法
  • MFC界面库BCGControlBar v32.1 - 可视化管理器和主题升级
  • css的浮动详解
  • qq里测试音色的软件,QQ换音大师2015(QQ消息提示声音修改软件)
  • Flash Player Debugger下载(9/10版本)