无为清净楼资源网 Design By www.qnjia.com
本文实例讲述了js实现从右向左缓缓浮出网页浮动层广告的方法。分享给大家供大家参考。具体实现方法如下:
<!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" /> <title>从右向左缓缓浮出的网页浮动层广告</title> <script language="javascript"> var $ = function (d){return document.getElementById(d)}; var CLS={ create: function() { return function() { this.$ADD = function (fn){CLS.add(this,fn)}; this.init.apply(this, arguments); } }, add:function (obj,fn){ fn.apply(obj,arguments); }, enterFrame:function (){ this.onEnterFrame=function (){}; this.$PLAY = function (g){ this.enterFrameP = this.enterFrameP || 10; this.CLStimeIndex = CLS.ontimes.length; CLS.ontimes.push(this); window.clearTimeout(this.enterFrameTimeout); window.clearInterval(this.enterFrameInterval); if(g)this.enterFrameTimeout = window.setTimeout('CLS.ontimes['+this.CLStimeIndex+'].enterFrameInterval=window.setInterval("CLS.ontimes['+this.CLStimeIndex+'].onEnterFrame()",'+this.enterFrameP+')',parseInt(g*1000)); else this.enterFrameInterval = window.setInterval("CLS.ontimes["+this.CLStimeIndex+"].onEnterFrame()",this.enterFrameP); } this.$STOP = function (){ window.clearInterval(this.enterFrameInterval); } this.$SET = function (p){ this.enterFrameP = p; } }, ontimes:new Array() }; CLS.Marquee = CLS.create(); CLS.Marquee.prototype = { init:function (button,box,speed){ this.box = $(box); this.tit = $(button) this.kong = $("kong"); this.onOpen = true; this.show = false; this.time = 0; this.speed = speed; this.kong.style.height = this.box.offsetHeight +"px"; this.Maxw = this.box.offsetWidth-this.tit.offsetWidth; this.box.style.right = -this.box.offsetWidth + "px"; this.boxTop = this.kong.offsetTop; var _t = this; this.tit.onclick = function (){ this.show = true; if(_t.onOpen){ _t.onEnterFrame = _t.close; _t.onOpen = false; }else{ _t.onEnterFrame = _t.open; _t.onOpen = true; } _t.$PLAY(); }; this.$ADD(CLS.enterFrame); this.onEnterFrame = this.open; this.$PLAY(); }, open:function(){ this.tit.innerHTML = "-"; var _r = parseInt(this.box.style.right); var _b = (0 - _r)/30; this.box.style.right = (_r + _b) +"px"; this.kong.style.top = (document.documentElement.scrollTop + this.boxTop) +"px"; if(_b==0 && !this.show){ this.time +=10; if(this.time>=this.speed*1000){ this.show = true; this.onOpen = false; this.$STOP(); this.onEnterFrame = this.close; this.$PLAY(); } } }, close:function (){ this.tit.innerHTML = "+"; var _r = parseInt(this.box.style.right); var _b = (-this.Maxw - _r)/5; this.box.style.right = Math.round(_r + _b) +"px"; this.kong.style.top = (document.documentElement.scrollTop + this.boxTop) +"px"; } }; window.onload = function (){ setTimeout(function(){new CLS.Marquee("tit","abc",10)},3000); //tit是点击按钮的Id ,abc是浮动块的ID,10是显示时长 }; </script> <style type="text/css"> <!-- #abc { border: 1px solid #003399; position: absolute; height: 150px; width: 220px; right: -100%; } #abc #tit { background-color: #0066FF; position: relative; height: 100%; width: 20px; color: #FFFFFF; text-align: center; float: left; } #kong { position: absolute; width: 100%; top: 100px; overflow: hidden; top: 100px; right: 0px; } .right { float: right; width: 190px; padding: 5px; } --> </style> </head> <body style="margin:0px;"> <!--浮动框外面套一层,防止出现横向滚动条--> <div id="kong"> <!--浮动框--> <div id="abc"> <div id="tit">-</div> <div class="right"> <a href="/">网页上从右边缓缓弹出的广告框效果</a></div> </div> </div> 右侧广告3秒后弹出 </body> </html>
希望本文所述对大家的javascript程序设计有所帮助。
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年11月20日
2024年11月20日
- 柏菲·珞叔作品集《金色大厅2》限量开盘母带ORMCD[低速原抓WAV+CUE]
- Gareth.T《sad songs(Explicit)》[320K/MP3][29.03MB]
- Gareth.T《sad songs(Explicit)》[FLAC/分轨][152.85MB]
- 证声音乐图书馆《海风摇曳·盛夏爵士曲》[320K/MP3][63.06MB]
- 龚玥《金装龚玥HQCD》头版限量[WAV分轨]
- 李小春《吻别》萨克斯演奏经典[原抓WAV+CUE]
- 齐秦《辉煌30年24K珍藏版》2CD[WAV+CUE]
- 证声音乐图书馆《海风摇曳·盛夏爵士曲》[FLAC/分轨][321.47MB]
- 群星 《世界经典汽车音乐》 [WAV分轨][1G]
- 冷漠.2011 《冷漠的爱DSD》[WAV+CUE][1.2G]
- 陈明《流金岁月精逊【中唱】【WAV+CUE】
- 群星《Jazz-Ladies1-2爵士女伶1-2》HQCD/2CD[原抓WAV+CUE]
- 群星《美女私房歌》(黑胶)[WAV分轨]
- 郑源.2009《试音天碟》24BIT-96KHZ[WAV+CUE][1.2G]
- 飞利浦试音碟 《环球群星监听录》SACD香港版[WAV+CUE][1.1G]