学做全屏浮动广告 JS 原生代码

<!DOCTYPE HTML>
<html><head><title>JS全屏漂浮广告</title>
<meta http-equiv=Content-Type content="text/html; charset=gbk">
<style type=text/css>
  div#roll {
	width: 100px; color: #fff; position: absolute; height: 100px; background-color: #000
}
</style>
<body>
<H2>JS全屏漂浮广告,移入光标停止移动</H2>
<div id="roll">我是广告</div>
<script type=text/javascript>
  var ggRoll = {
    roll: document.getElementById("roll"),
    speed: 20,
    statusX: 1,
    statusY: 1,
    x: 100,
    y: 300,
    winW: document.documentElement.clientWidth - document.getElementById("roll").offsetWidth,
    winH: document.documentElement.clientHeight - document.getElementById("roll").offsetHeight,
    Go: function () {
       this.roll.style.left = this.x + 'px';
       this.roll.style.top = this.y + 'px';

       this.x = this.x + (this.statusX ? -1 : 1)
       if (this.x < 0) { this.statusX = 0 }
       if (this.x > this.winW) { this.statusX = 1 }

       this.y = this.y + (this.statusY ? -1 : 1)
       if (this.y < 0) { this.statusY = 0 }
       if (this.y > this.winH) { this.statusY = 1 }

     }
  };
    var interval = setInterval("ggRoll.Go()", ggRoll.speed);
    ggRoll.roll.onmouseover = function () { clearInterval(interval) };
    ggRoll.roll.onmouseout = function () { interval = setInterval("ggRoll.Go()", ggRoll.speed) };

</script>
</body></html>

<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title></title> <link rel="stylesheet" href="css/index.css" type="text/css" media="screen" /> <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script> <script type="text/javascript" src="js/index.js"></script> <!--[if lt IE 7]> <link rel="stylesheet" href="css_2/ie6.css?v000020" type="text/css" media="screen" /> <script type="text/javascript" src="js/ie6.js?v000020"></script> <![endif]--> </head> <body> <div class="pub_c"> <div class="m_banner"> <div class="banner b1" style=" background-image:url(images/banner_2.jpg);" id="banner1"> <div class="main_c pr"> <a href="#" title="" class="start_btn"></a> </div> </div> <div class="banner b5" style=" background-image:url(images/banner_17.jpg);display:none;" id="banner5"> <div class="main_c"> <a href="#" target="_blank" title="" class="l1"></a> <div class="countdown"> <span class="num_1 fsm">0</span> <span class="num_2 fsm">0</span> </div> </div> </div> <div class="banner b2" style=" background-image:url(images/banner_12.jpg);display:none;" id="banner2"> <div class="main_c pr"> <p>更多新功能介绍及教程请 <a href="#" target="_blank" title="">点击此处</a> 或咨询 <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=123456&site=qq&menu=yes" title="">客服QQ</a> / <a target="_blank" href="http://crm2.qq.com/page/portalpage/wpa.php?uin=123456&f=1&ty=1&aty=0&a=&from=6" title="">商务QQ</a></p> </div> </div> <div class="banner b3" style=" background-image:url(images/banner_3.jpg);display:none;" id="banner3"> </div> <div class="banner b4" style=" background-image:url(images/banner_4.jpg);display:none;" id="banner4"> <div class="main_c pr"> <a href="#" title="" class="start_btn">查看详情</a> </div> </div> <div class="banner_ctrl"> <a href="#" class="prev" title=""></a> <a href="javascript:;" class="next" title=""></a> </div> </div> </body> </html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值