到处乱飘的飘浮广告


关键词

飘浮 广告 js

摘要

本文介绍一个飘浮广告的js脚本,向四周飘浮,撞墙回弹效果。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="gbk" />
    <title>到处乱飘的广告</title>
    <meta name="keywords" content="" />
    <meta name="description" content=""    />
</head>
<body>

<div id="piaofu" style="position:absolute; border:0px solid #ccc;">
    <div style="text-align:right;">
        <a href="javascript:void(0)" onclick="javascript:closePiaofu()" style="background-color: #A00;color:#fff; padding:0px 5px; text-decoration:none; font-size:12px;">[关闭]</a>
    </div>
    <a href="http://www.web100.cc" target="_blank" style="">
        <img src="http://www.web100.cc/webui/images/logo.png" border="0" width="315" height="81" />
    </a>
</div>
<script>

function closePiaofu(){
    document.getElementById("piaofu").style.display = "none";
}

var x = 50,y = 160;
var xin = true, yin = true;
var step = 0.8;
var delay = 10;
var obj=document.getElementById("piaofu");
function piaofu(){
    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("piaofu()", delay);    
obj.onmouseover=function(){clearInterval(itl)}
obj.onmouseout=function(){itl=setInterval("piaofu()", delay)}

</script>

<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;
<p>&nbsp;

</body>
</html>

 

文章的版权

洪哥写文章很苦逼,如果本文对您略有帮助,点击感兴趣的广告支持洪哥!万分感谢!本文属于“洪哥笔记”原创文章,转载请注明来源地址:到处乱飘的飘浮广告:http://www.splaybow.com/post/piaofu-guanggao-js.html

关注与收藏

如果您在服务器运维、网络管理、网站或系统开发过程有需要提供收费服务,请加QQ:115085382!十年运维经验,帮您省钱、让您放心!
亲,如果有需要,先存起来,方便以后再看啊!加入收藏夹的话,按Ctrl+D


« js获取QueryString里面的参数值 生成圆圈小图标的js工具 »