zoukankan      html  css  js  c++  java
  • 随机漂浮图片广告实例代码

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=" utf-8">
    <meta name="author" content="http://www.softwhy.com/" />
    <title>漂浮广告代码-蚂蚁部落</title>
    <style type="text/css">
    #thediv
    {
    z-index:100;
    position:absolute;
    top:43px;
    left:2px;
    height:100px;
    100px;
    background-color:red;
    }
    </style>
    <script type="text/javascript">
    var xPos=300;
    var yPos=200;
    var step=1;
    var delay=8;
    var height=0;
    var Hoffset=0;
    var Woffset=0;
    var yon=0;
    var xon=0;
    var pause=true;
    var interval;
    function changePos()
    {
    width=document.documentElement.clientWidth;
    height=document.documentElement.clientHeight;
    Hoffset=thediv.offsetHeight;
    Woffset=thediv.offsetWidth;
    thediv.style.left=(xPos+document.body.scrollLeft+document.documentElement.scrollLeft)+"px";
    thediv.style.top=(yPos+document.body.scrollTop+document.documentElement.scrollTop)+"px";
    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()
    {
    thediv.visibility="visible";
    interval=setInterval('changePos()',delay);
    }
    function pause_resume()
    {
    if(pause)
    {
    clearInterval(interval);
    pause = false;
    }
    else
    {
    interval = setInterval(changePos,delay);
    pause = true;
    }
    }
    window.onload=function()
    {
    thediv.style.top=yPos;
    start();
    }
    </script>
    </head>
    <body>
    <div id="thediv"></div>
    </body>
    </html>

  • 相关阅读:
    Python列表去重
    hash表长度优化证明
    DDD初学指南
    继承和实现的明显区别
    微信商户支付
    centos7+mono4+jexus5.6.2安装过程中的遇到的问题
    SVN:重命名文件之后不允许提交
    SpringMVC 自定义全局日期转换器
    解决Cannot change version of project facet Dynamic web module to 2.5
    Maven项目热部署到Tomcat容器下
  • 原文地址:https://www.cnblogs.com/hgbgfg/p/5205724.html
Copyright © 2011-2022 走看看