<script language=javascript> <br> <!-- <br> <br> /**//* <br> ** ================================================================================================== <br> ** 类名:class_msn_message <br> ** 功能:提供类似msn消息框 <br> ** 示例: <br> --------------------------------------------------------------------------------------------------- <br> <br> var msg = new class_msn_message("aa",200,120,"短消息提示:","您有1封消息","今天请我吃饭哈"); <br> msg.show(); <br> <br> --------------------------------------------------------------------------------------------------- <br> ** 作者:ttyp <br> ** 邮件:<a href="mailto:ttyp@21cn.com">ttyp@21cn.com</a> <br> ** 日期:2005-3-18 <br> ** ================================================================================================== <br> **/ <br> <br> <br> /**//* <br> * 消息构造 <br> */ <br> function class_msn_message(id,width,height,caption,title,message,target,action){ <br> this.id = id; <br> this.title = title; <br> this.caption= caption; <br> this.message= message; <br> this.target = target; <br> this.action = action; <br> this.width = width?width:200; <br> this.height = height?height:120; <br> this.timeout= 150; <br> this.speed = 20; <br> this.step = 1; <br> this.right = screen.width -1; <br> this.bottom = screen.height; <br> this.left = this.right - this.width; <br> this.top = this.bottom - this.height; <br> this.timer = 0; <br> this.pause = false;<br> this.close = false;<br> this.autohide = true;<br> } <br> <br> /**//* <br> * 隐藏消息方法 <br> */ <br> class_msn_message.prototype.hide = function(){ <br> if(this.onunload()){ </p> <p> var offset = this.height>this.bottom-this.top?this.height:this.bottom-this.top; <br> var me = this; </p> <p> if(this.timer>0){ <br> window.clearinterval(me.timer); <br> } </p> <p> var fun = function(){ <br> if(me.pause==false||me.close){<br> var x = me.left; <br> var y = 0; <br> var width = me.width; <br> var height = 0; <br> if(me.offset>0){ <br> height = me.offset; <br> } <br> <br> y = me.bottom - height; <br> <br> if(y>=me.bottom){ <br> window.clearinterval(me.timer); <br> me.pop.hide(); <br> } else { <br> me.offset = me.offset - me.step; <br> } <br> me.pop.show(x,y,width,height); <br> } <br> } </p> <p> this.timer = window.setinterval(fun,this.speed) <br> } <br> } <br> <br> /**//* <br> * 消息卸载事件,可以重写 <br> */ <br> class_msn_message.prototype.onunload = function() { <br> return true; <br> } <br> /**//* <br> * 消息命令事件,要实现自己的连接,请重写它 <br> * <br> */ <br> class_msn_message.prototype.oncommand = function(){ <br> //this.close = true;<br> this.hide(); <br> window.open("<a href="http://www.baidu.com">http://www.baidu.com</a>");<br> <br> } <br> /**//* <br> * 消息显示方法 <br> */ <br> class_msn_message.prototype.show = function(){ </p> <p> var opopup = window.createpopup(); //ie5.5+ <br> <br> this.pop = opopup; <br> <br> var w = this.width; <br> var h = this.height; <br> <br> var str = "<div style=’border-right: #455690 1px solid; border-top: #a6b4cf 1px solid; z-index: 99999; left: 0px; border-left: #a6b4cf 1px solid; width: " + w + "px; border-bottom: #455690 1px solid; position: absolute; top: 0px; height: " + h + "px; background-color: #c9d3f3’>" <br> str += "<table style=’border-top: #ffffff 1px solid; border-left: #ffffff 1px solid’ cellspacing=0 cellpadding=0 width=’100%’ bgcolor=#cfdef4 border=0>" <br> str += "<tr>" <br> str += "<td style=’font-size: 12px;color: #0f2c8c’ width=30 height=24></td>" <br> str += "<td style=’padding-left: 4px; font-weight: normal; font-size: 12px; color: #1f336b; padding-top: 4px’ valign=center width=’100%’>" + this.caption + "</td>" <br> str += "<td style=’padding-right: 2px; padding-top: 2px’ valign=center align=right width=19>" <br> str += "<span title=关闭 style=’font-weight: bold; font-size: 12px; cursor: hand; color: red; margin-right: 4px’ id=’btsysclose’ >×</span></td>" <br> str += "</tr>" <br> str += "<tr>" <br> str += "<td style=’padding-right: 1px;padding-bottom: 1px’ colspan=3 height=" + (h-28) + ">" <br> str += "<div style=’border-right: #b9c9ef 1px solid; padding-right: 8px; border-top: #728eb8 1px solid; padding-left: 8px; font-size: 12px; padding-bottom: 8px; border-left: #728eb8 1px solid; width: 100%; color: #1f336b; padding-top: 8px; border-bottom: #b9c9ef 1px solid; height: 100%’>" + this.title + "<br><br>" <br> str += "<div style=’word-break: break-all’ align=left><a href=’javascript:void(0)’ hidefocus=false id=’btcommand’><font color=#ff0000>" + this.message + "</font></a>fghfghfghghghgh<a href=’http://www.sohu.com’ hidefocus=false id=’ommand’><font color=#ff0000>dfgdfgfg</font></a></div>" <br> str += "</div>" <br> str += "</td>" <br> str += "</tr>" <br> str += "</table>" <br> str += "</div>" <br> <br> opopup.document.body.innerhtml = str; <br> <br> <br> this.offset = 0; <br> var me = this; </p> <p> opopup.document.body.onmouseover = function(){me.pause=true;}<br> opopup.document.body.onmouseout = function(){me.pause=false;}</p> <p> var fun = function(){ <br> var x = me.left; <br> var y = 0; <br> var width = me.width; <br> var height = me.height; </p> <p> if(me.offset>me.height){ <br> height = me.height; <br> } else { <br> height = me.offset; <br> } </p> <p> y = me.bottom - me.offset; <br> if(y<=me.top){ <br> me.timeout--; <br> if(me.timeout==0){ <br> window.clearinterval(me.timer); <br> if(me.autohide){<br> me.hide(); <br> }<br> } <br> } else { <br> me.offset = me.offset + me.step; <br> } <br> me.pop.show(x,y,width,height); </p> <p> } <br> <br> this.timer = window.setinterval(fun,this.speed) <br> <br> <br> <br> var btclose = opopup.document.getelementbyid("btsysclose"); <br> <br> btclose.onclick = function(){ <br> me.close = true;<br> me.hide(); <br> } <br> <br> var btcommand = opopup.document.getelementbyid("btcommand"); <br> btcommand.onclick = function(){ <br> me.oncommand(); <br> } <br> var ommand = opopup.document.getelementbyid("ommand"); <br> ommand.onclick = function(){ <br> //this.close = true;<br> me.hide(); <br> window.open(ommand.href);<br> } <br> } <br> /**//* <br> ** 设置速度方法 <br> **/ <br> class_msn_message.prototype.speed = function(s){ <br> var t = 20; <br> try { <br> t = praseint(s); <br> } catch(e){} <br> this.speed = t; <br> } <br> /**//* <br> ** 设置步长方法 <br> **/ <br> class_msn_message.prototype.step = function(s){ <br> var t = 1; <br> try { <br> t = praseint(s); <br> } catch(e){} <br> this.step = t; <br> } <br> <br> class_msn_message.prototype.rect = function(left,right,top,bottom){ <br> try { <br> this.left = left !=null?left:this.right-this.width; <br> this.right = right !=null?right:this.left +this.width; <br> this.bottom = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height; <br> this.top = top !=null?top:this.bottom - this.height; <br> } catch(e){} <br> } <br> function _mess(){<br> var msg1 = new class_msn_message("aa",200,120,"短消息提示:","您有1封消息","今天请我吃饭哈"); <br> msg1.rect(null,null,null,screen.height-50); <br> msg1.speed = 10; <br> msg1.step = 5; <br> //alert(msg1.top); <br> msg1.show(); <br> }<br> setinterval(_mess,5500)//间隔单位,1000=1秒<br> //同时两个有闪烁,只能用层代替了,不过层不跨框架 <br> //var msg2 = new class_msn_message("aa",200,120,"短消息提示:","您有2封消息","好的啊"); <br> //msg2.rect(100,null,null,screen.height); <br> //msg2.show(); <br> //--> <br> </script>
1万+




被折叠的 条评论
为什么被折叠?



