网钛建站代码交易区

简单的左上至左下的漂浮代码

0
时间:2016-3-17 12:37:23  作者:摘编  来源:转载  查看:80  评论:0
<div id="img" style="position:absolute;">
<a href="http://qujianzhan.com"><img src="http://img.bimg.126.net/photo/m866eVcx9IQg-IFM6_fSYg==/229120631042758508.jpg" onClick="pause_resume();" style="border:none"></href></a>
</div>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var xPos = 20;
var yPos = document.body.clientHeight;
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;
img.style.top = yPos;
function changePos() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = img.offsetHeight;
Woffset = img.offsetWidth;
img.style.left = xPos + document.body.scrollLeft;
img.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() {
img.visibility = "visible";
interval = setInterval('changePos()', delay);
}
function pause_resume() {
if(pause) {
clearInterval(interval);
pause = false;
}
else {
interval = setInterval('changePos()',delay);
pause = true;
   }
}
start();
//  End -->
</script>


相关文章
    相关评论
    评论者:      验证码:  点击获取验证码
    本类推荐
      书签  |  以太坊  |  pc蛋蛋群  |  杭州公寓楼盘价格  |  
          区间站线报交换网,加QQ群免费看线报
      ①线报付费群440190499②京东券交换群681633372 
         一次联系终身朋友即时回复:一次联系,终身朋友)
                   
      苏ICP备10228228号-1