首页漂浮图片,保存称html即可看效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 </head>
 <body>
  <div id="body">
     <!--漂浮图片 2017.5.24-->
   <div id="float_AD" style="position:absolute;z-index:1000;" οnmοuseοver="window.clearInterval(timer)" οnmοuseοut="timer=window.setInterval('changePos()',delay);">
    <a href="http://www.iterchina.cn/"><img src="https://img-blog.csdn.net/20170524093248122" style="width:300px; height:300px;" /></a>
    <span style="CURSOR:hand;color:red;font-weight:bold" οnclick="clearInterval(timer);obj.style.visibility = 'hidden'">X</span>
   </div>
   <script type="text/javascript" language="JavaScript">
   var obj=document.getElementById("float_AD");
   var clientHeight=document.documentElement.clientHeight;
   var clientWidth=document.documentElement.clientWidth;
   var timer; var delay= 20;//移动速度
   function randomNum(size){ return Math.floor(Math.random()*(size-160+1)); }
   obj.style.top=randomNum(clientHeight)+"px";
   obj.style.left=randomNum(clientWidth)+"px";
   var y=parseInt(obj.style.top);
   var x=parseInt(obj.style.left);
   var flagX=false; var flagY=true;
   function moveY(){ if(flagY){ y++; if(y>clientHeight-160){ flagY=false; } }else{ y--; if(y<0){ flagY=true; } } obj.style.top=y+"px"; }
   function moveX(){ if(flagX){ x++; if(x>clientWidth-160){ flagX=false; } }else{ x--; if(x<0){ flagX=true; } } obj.style.left=x+"px"; }
   window.οnresize=function(){ clientHeight=document.documentElement.clientHeight; clientWidth=document.documentElement.clientWidth; }
   function changePos(){moveY();moveX(); }
   function creatTimer(){timer = window.setInterval("changePos();",delay); }
   function hide() {obj.style.display = "none";
   obj.onmouseout = function() {obj.style.visibility = "hidden";}}
   var url = window.location.href;if (true) {creatTimer();} else {hide();}// url == "http://www.xxxxx.cn/"
   </script>

 </body>
</html>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值