Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  javascript  >  正文 js漂浮广告代码 js弹性漂浮广告

js漂浮广告代码 js弹性漂浮广告

发布时间:2015-07-07   编辑:www.jquerycn.cn
本文介绍了js物理性漂浮广告的代码,js漂浮广告的小例子,实现广告图处的全屏漂浮移动,有需要的朋友参考下。

1,js漂浮广告代码 js.js
 

复制代码 代码示例:
var xpos = 300;
var ypos = 200;
var step = 1;
var delay = 30;
var height = 0;
var hoffset = 0;
var woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
img1.style.top = ypos;
function changepos()
{
 width = document.body.clientwidth;
 height = document.body.clientheight;
 hoffset = img1.offsetheight;
 woffset = img1.offsetwidth;
 img1.style.left = xpos + document.body.scrollleft;
 img1.style.top = ypos + document.body.scrolltop;
 if (yon)
  {ypos = ypos + step;}
 else
  {ypos = ypos - step;}
 if (ypos < 0)
  {yon = 1;ypos = 0;}
 if (ypos >= (height - hoffset))
  {yon = 0;ypos = (height - hoffset);}
 if (xon)
  {xpos = xpos + step;}
 else
  {xpos = xpos - step;}
 if (xpos < 0)
  {xon = 1;xpos = 0;}
 if (xpos >= (width - woffset))
  {xon = 0;xpos = (width - woffset);   }
 }
 
 function start()
  {
   img1.visibility = "visible";
  interval = setinterval('changepos()', delay);
 }
 function pause_resume()
 {
  if(pause)
  {
   clearinterval(interval);
   pause = false;}
  else
  {
   interval = setinterval('changepos()',delay);
   pause = true;
   }
  }
 start();

2,html部分
 

复制代码 代码示例:
<body>
<div id=img1 style="z-index: 100; left: 2px; width: 59px; position: absolute; top: 43px; height: 61px;
 visibility: visible;"><a href="http://www.jquerycn.cn/" target="_blank"><img src="images/pic.gif" width="80" height="80" border="0"></a></div>
<script src="js/js.js"></script>
</body>

您可能感兴趣的文章:
js全屏漂浮广告代码 移入光标停止移动
js漂浮广告代码 js弹性漂浮广告
js漂浮广告代码示例
JS全屏漂浮广告、移入光标停止移动
js右侧漂浮广告的小例子
漂浮广告的经典js代码
js漂浮广告代码大全
js实现漂浮广告效果的代码
JS全屏漂浮广告代码
Js全屏漂浮广告效果的代码示例

关键词: 漂浮广告代码   
[关闭]