资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
可关闭与最小化的右下角浮动广告代码
很多朋友喜欢带有最小化功能的代码。
<!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> <title>可最小化和关闭的右下角浮动窗口</title> <meta http-equiv="content-type" content="text/html;charset=gb2312"> <style type="text/css"> #msg_win{position:absolute;right:0px;display:none;overflow:hidden;z-index:99;border:1px solid #c00;background:#F9EFFC;width:240px;font-size:12px;margin:0px;} #msg_win .icos{position:absolute;top:2px;*top:0px;right:2px;z-index:9;} .icos a{float:left;color:#FFFFFF;margin:1px;text-align:center;font-weight:bold;width:14px;height:22px;line-height:22px;padding:1px;text-decoration:none;font-family:webdings;} .icos a:hover{color:#FFCC00;} #msg_title{background:#AC19E3;border-bottom:1px solid #710B97;border-top:1px solid #FFF;border-left:1px solid #FFF;color:#FFFFFF;height:25px;line-height:25px;text-indent:5px;font-weight:bold;} #msg_content{margin:5px;margin-right:0;width:230px;height:126px;overflow:hidden;} </style> </head> <body> <div style="height:2000px;"></div> <div id="msg_win" style="display:block;top:503px;visibility:visible;opacity:1;"> <div class="icos"><a id="msg_min" title="最小化" href="javascript:void 0" _ewebeditor_ta_href="javascript%3Avoid%200">_</a><a id="msg_close" title="关闭" href="javascript:void 0" _ewebeditor_ta_href="javascript%3Avoid%200">×</a></div> <div id="msg_title">浮动窗口标题:</div> <div id="msg_content">浮动窗口内容:欢迎提出宝贵意见,谢谢!</div> </div> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20language%3D%22javascript%22%3E%20%0D%0Avar%20Message%3D%7B%20%0D%0Aset%3A%20function()%20%7B%2F%2F%E6%9C%80%E5%B0%8F%E5%8C%96%E4%B8%8E%E6%81%A2%E5%A4%8D%E7%8A%B6%E6%80%81%E5%88%87%E6%8D%A2%20%0D%0Avar%20set%3Dthis.minbtn.status%20%3D%3D%201%3F%5B0%2C1%2C'block'%2Cthis.char%5B0%5D%2C'%E6%9C%80%E5%B0%8F%E5%8C%96'%5D%3A%5B1%2C0%2C'none'%2Cthis.char%5B1%5D%2C'%E6%81%A2%E5%A4%8D'%5D%3B%20%0D%0Athis.minbtn.status%3Dset%5B0%5D%3B%20%0D%0Athis.win.style.borderBottomWidth%3Dset%5B1%5D%3B%20%0D%0Athis.content.style.display%20%3Dset%5B2%5D%3B%20%0D%0Athis.minbtn.innerHTML%20%3Dset%5B3%5D%20%0D%0Athis.minbtn.title%20%3D%20set%5B4%5D%3B%20%0D%0Athis.win.style.top%20%3D%20this.getY().top%3B%20%0D%0A%7D%2C%20%0D%0Aclose%3A%20function()%20%7B%2F%2F%E5%85%B3%E9%97%AD%20%0D%0Athis.win.style.display%20%3D%20'none'%3B%20%0D%0Awindow.onscroll%20%3D%20null%3B%20%0D%0A%7D%2C%20%0D%0AsetOpacity%3A%20function(x)%20%7B%2F%2F%E8%AE%BE%E7%BD%AE%E9%80%8F%E6%98%8E%E5%BA%A6%20%0D%0Avar%20v%20%3D%20x%20%3E%3D%20100%20%3F%20''%3A%20'Alpha(opacity%3D'%20%2B%20x%20%2B%20')'%3B%20%0D%0Athis.win.style.visibility%20%3D%20x%3C%3D0%3F'hidden'%3A'visible'%3B%2F%2FIE%E6%9C%89%E7%BB%9D%E5%AF%B9%E6%88%96%E7%9B%B8%E5%AF%B9%E5%AE%9A%E4%BD%8D%E5%86%85%E5%AE%B9%E4%B8%8D%E9%9A%8F%E7%88%B6%E9%80%8F%E6%98%8E%E5%BA%A6%E5%8F%98%E5%8C%96%E7%9A%84bug%20%0D%0Athis.win.style.filter%20%3D%20v%3B%20%0D%0Athis.win.style.opacity%20%3D%20x%20%2F%20100%3B%20%0D%0A%7D%2C%20%0D%0Ashow%3A%20function()%20%7B%2F%2F%E6%B8%90%E6%98%BE%20%0D%0AclearInterval(this.timer2)%3B%20%0D%0Avar%20me%20%3D%20this%2Cfx%20%3D%20this.fx(0%2C%20100%2C%200.1)%2Ct%20%3D%200%3B%20%0D%0Athis.timer2%20%3D%20setInterval(function()%20%7B%20%0D%0At%20%3D%20fx()%3B%20%0D%0Ame.setOpacity(t%5B0%5D)%3B%20%0D%0Aif%20(t%5B1%5D%20%3D%3D%200)%20%7BclearInterval(me.timer2)%20%7D%20%0D%0A%7D%2C6)%3B%2F%2F10%20to%206%20%0D%0A%7D%2C%20%0D%0Afx%3A%20function(a%2C%20b%2C%20c)%20%7B%2F%2F%E7%BC%93%E5%86%B2%E8%AE%A1%E7%AE%97%20%0D%0Avar%20cMath%20%3D%20Math%5B(a%20-%20b)%20%3E%200%20%3F%20%22floor%22%3A%20%22ceil%22%5D%2Cc%20%3D%20c%20%7C%7C%200.1%3B%20%0D%0Areturn%20function()%20%7Breturn%20%5Ba%20%2B%3D%20cMath((b%20-%20a)%20*%20c)%2C%20a%20-%20b%5D%7D%20%0D%0A%7D%2C%20%0D%0AgetY%3A%20function()%20%7B%2F%2F%E8%AE%A1%E7%AE%97%E7%A7%BB%E5%8A%A8%E5%9D%90%E6%A0%87%20%0D%0Avar%20d%20%3D%20document%2Cb%20%3D%20document.body%2C%20e%20%3D%20document.documentElement%3B%20%0D%0Avar%20s%20%3D%20Math.max(b.scrollTop%2C%20e.scrollTop)%3B%20%0D%0Avar%20h%20%3D%20%2FBackCompat%2Fi.test(document.compatMode)%3Fb.clientHeight%3Ae.clientHeight%3B%20%0D%0Avar%20h2%20%3D%20this.win.offsetHeight%3B%20%0D%0Areturn%20%7Bfoot%3A%20s%20%2B%20h%20%2B%20h2%20%2B%202%2B'px'%2Ctop%3A%20s%20%2B%20h%20-%20h2%20-%202%2B'px'%7D%20%0D%0A%7D%2C%20%0D%0AmoveTo%3A%20function(y)%20%7B%2F%2F%E7%A7%BB%E5%8A%A8%E5%8A%A8%E7%94%BB%20%0D%0AclearInterval(this.timer)%3B%20%0D%0Avar%20me%20%3D%20this%2Ca%20%3D%20parseInt(this.win.style.top)%7C%7C0%3B%20%0D%0Avar%20fx%20%3D%20this.fx(a%2C%20parseInt(y))%3B%20%0D%0Avar%20t%20%3D%200%20%3B%20%0D%0Athis.timer%20%3D%20setInterval(function()%20%7B%20%0D%0At%20%3D%20fx()%3B%20%0D%0Ame.win.style.top%20%3D%20t%5B0%5D%2B'px'%3B%20%0D%0Aif%20(t%5B1%5D%20%3D%3D%200)%20%7B%20%0D%0AclearInterval(me.timer)%3B%20%0D%0Ame.bind()%3B%20%0D%0A%7D%20%0D%0A%7D%2C6)%3B%2F%2F10%20to%206%20%0D%0A%7D%2C%20%0D%0Abind%3Afunction%20()%7B%2F%2F%E7%BB%91%E5%AE%9A%E7%AA%97%E5%8F%A3%E6%BB%9A%E5%8A%A8%E6%9D%A1%E4%B8%8E%E5%A4%A7%E5%B0%8F%E5%8F%98%E5%8C%96%E4%BA%8B%E4%BB%B6%20%0D%0Avar%20me%3Dthis%2Cst%2Crt%3B%20%0D%0Awindow.onscroll%20%3D%20function()%20%7B%20%0D%0AclearTimeout(st)%3B%20%0D%0AclearTimeout(me.timer2)%3B%20%0D%0Ame.setOpacity(0)%3B%20%0D%0Ast%20%3D%20setTimeout(function()%20%7B%20%0D%0Ame.win.style.top%20%3D%20me.getY().top%3B%20%0D%0Ame.show()%3B%20%0D%0A%7D%2C100)%3B%2F%2F600%20mod%20100%20%0D%0A%7D%3B%20%0D%0Awindow.onresize%20%3D%20function%20()%7B%20%0D%0AclearTimeout(rt)%3B%20%0D%0Art%20%3D%20setTimeout(function()%20%7Bme.win.style.top%20%3D%20me.getY().top%7D%2C100)%3B%20%0D%0A%7D%20%0D%0A%7D%2C%20%0D%0Ainit%3A%20function()%20%7B%2F%2F%E5%88%9B%E5%BB%BAHTML%20%0D%0Afunction%20%24(id)%20%7Breturn%20document.getElementById(id)%7D%3B%20%0D%0Athis.win%3D%24('msg_win')%3B%20%0D%0Avar%20set%3D%7Bminbtn%3A%20'msg_min'%2Cclosebtn%3A%20'msg_close'%2Ctitle%3A%20'msg_title'%2Ccontent%3A%20'msg_content'%7D%3B%20%0D%0Afor%20(var%20Id%20in%20set)%20%7Bthis%5BId%5D%20%3D%20%24(set%5BId%5D)%7D%3B%20%0D%0Avar%20me%20%3D%20this%3B%20%0D%0Athis.minbtn.onclick%20%3D%20function()%20%7Bme.set()%3Bthis.blur()%7D%3B%20%0D%0Athis.closebtn.onclick%20%3D%20function()%20%7Bme.close()%7D%3B%20%0D%0Athis.char%3Dnavigator.userAgent.toLowerCase().indexOf('firefox')%2B1%3F%5B'_'%2C'%3A%3A'%2C'%C3%97'%5D%3A%5B'0'%2C'2'%2C'r'%5D%3B%2F%2FFF%E4%B8%8D%E6%94%AF%E6%8C%81webdings%E5%AD%97%E4%BD%93%20%0D%0Athis.minbtn.innerHTML%3Dthis.char%5B0%5D%3B%20%0D%0Athis.closebtn.innerHTML%3Dthis.char%5B2%5D%3B%20%0D%0AsetTimeout(function()%20%7B%2F%2F%E5%88%9D%E5%A7%8B%E5%8C%96%E6%9C%80%E5%85%88%E4%BD%8D%E7%BD%AE%20%0D%0Ame.win.style.display%20%3D%20'block'%3B%20%0D%0Ame.win.style.top%20%3D%20me.getY().foot%3B%20%0D%0Ame.moveTo(me.getY().top)%3B%20%0D%0A%7D%2C0)%3B%20%0D%0Areturn%20this%3B%20%0D%0A%7D%20%0D%0A%7D%3B%20%0D%0AMessage.init()%3B%20%0D%0A%3C%2Fscript%3E"> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程