仿QQ弹出窗口
最近在做内部管理,需要用到这个东西来提醒,所以就把它做成一个类,直接调用,满方便的.贴一下代码,大家看一下
Code
1 using System;
2 using System.Web;
3 using System.Collections.Generic;
4 using System.Text;
5
6 /****************************************
7 * 作者:wenjl
8 * 功能:使用该类,可以实现右下角的弹出界面。
9 * 日期:2008-10-26
10 * 版本:0.1
11 * **************************************/
12 namespace PopupMessage
13 {
14 /// <summary>
15 /// 使用该类,可以实现右下角的弹出界面。
16 /// </summary>
17 public class PopupMessage
18 {
19 private StringBuilder m_Script;
20
21 #region PopupMessage构造函数。
22 /// <summary>
23 /// 构告出弹出界面的前台脚本。
24 /// </summary>
25 public PopupMessage()
26 {
27 m_Script = new StringBuilder();
28 #region Script
29 m_Script.Append("<SCRIPT language=\"JavaScript\" type=\"text/javascript\"> \n ");
30 // m_Script.Append("<!-- \n ");
31 m_Script.Append("function CLASS_MSN_MESSAGE(id,width,height,caption,message,target,action){ \n ");
32 m_Script.Append("this.id = id; \n ");
33 m_Script.Append("this.caption= caption; \n ");
34 m_Script.Append("this.message= message; \n ");
35 m_Script.Append("this.target = target; \n ");
36 m_Script.Append("this.action = action; \n ");
37 m_Script.Append("this.width = width; \n ");
38 m_Script.Append("this.height = height; \n ");
39 m_Script.Append("this.timeout= 2000; \n ");
40 m_Script.Append("this.speed = 20; \n ");
41 m_Script.Append("this.step = 1; \n ");
42 m_Script.Append("this.right = screen.width -1; \n ");
43 m_Script.Append("this.bottom = screen.height; \n ");
44 m_Script.Append("this.left = this.right - this.width; \n ");
45 m_Script.Append("this.top = this.bottom - this.height; \n ");
46 m_Script.Append("this.timer = 0; \n ");
47 m_Script.Append("this.pause = false;\n ");
48 m_Script.Append("this.close = false;\n ");
49 m_Script.Append("this.autoHide = true;\n ");
50 m_Script.Append("} \n ");
51 m_Script.Append("/* \n ");
52 m_Script.Append("* 隐藏消息方法 \n ");
53 m_Script.Append("*/ \n ");
54 m_Script.Append("CLASS_MSN_MESSAGE.prototype.hide = function(){ \n ");
55 m_Script.Append("if(this.onunload()){ \n ");
56 m_Script.Append("var offset = this.height>this.bottom-this.top?this.height:this.bottom-this.top; \n ");
57 m_Script.Append("var me = this; \n ");
58 m_Script.Append("if(this.timer>0){ \n ");
59 m_Script.Append("window.clearInterval(me.timer); \n ");
60 m_Script.Append("} \n ");
61 m_Script.Append("var fun = function(){ \n ");
62 m_Script.Append("if(me.pause==false||me.close){\n ");
63 m_Script.Append("var x = me.left; \n ");
64 m_Script.Append("var y = 0; \n ");
65 m_Script.Append("var width = me.width; \n ");
66 m_Script.Append("var height = 0; \n ");
67 m_Script.Append("if(me.offset>0){ \n ");
68 m_Script.Append("height = me.offset; \n ");
69 m_Script.Append("} \n ");
70 m_Script.Append("y = me.bottom - height; \n ");
71 m_Script.Append("if(y>=me.bottom){ \n ");
72 m_Script.Append("window.clearInterval(me.timer); \n ");
73 m_Script.Append("me.Pop.hide(); \n ");
74 m_Script.Append("} else { \n ");
75 m_Script.Append("me.offset = me.offset - me.step; \n ");
76 m_Script.Append("} \n ");
77 m_Script.Append("me.Pop.show(x,y,width,height); \n ");
78 m_Script.Append("} \n ");
79 m_Script.Append("} \n ");
80 m_Script.Append("this.timer = window.setInterval(fun,this.speed) \n ");
81 m_Script.Append("} \n ");
82 m_Script.Append("} \n ");
83 m_Script.Append("/* \n ");
84 m_Script.Append("* 消息卸载事件,可以重写 \n ");
85 m_Script.Append("*/ \n ");
86 m_Script.Append("CLASS_MSN_MESSAGE.prototype.onunload = function() { \n ");
87 m_Script.Append("return true; \n ");
88 m_Script.Append("} \n ");
89 m_Script.Append("/* \n ");
90 m_Script.Append("* 消息命令事件,要实现自己的连接,请重写它 \n ");
91 m_Script.Append("* \n ");
92 m_Script.Append("*/ \n ");
93 m_Script.Append("CLASS_MSN_MESSAGE.prototype.oncommand = function(){ \n ");
94 m_Script.Append("this.hide(); \n ");
95 m_Script.Append("} \n ");
96 m_Script.Append("/* \n ");
97 m_Script.Append("* 消息显示方法 \n ");
98 m_Script.Append("*/ \n ");
99 m_Script.Append("CLASS_MSN_MESSAGE.prototype.show = function(){ \n ");
100 m_Script.Append("var oPopup = window.createPopup(); /*IE5.5+ */ \n ");
101 m_Script.Append("this.Pop = oPopup; \n ");
102 m_Script.Append("var w = this.width; \n ");
103 m_Script.Append("var h = this.height; \n ");
104 m_Script.Append("var str = \"<div style='z-index: 99999;width:\" + w + \"px; height:\" + h + \"px;'>\" \n ");
105 m_Script.Append("str += \"<table width='\"+this.width+\"px' border='0' cellspacing='0' cellpadding='0'>\" \n ");
106 m_Script.Append("str += \"<tr><td width='36px' height=24><img src='images/msg/msg_03.gif' /></td>\" \n ");
107 m_Script.Append("str += \"<td style='font-size:12px; color:#FFF; font-weight:bold; line-height:20px; background:url(images/msg/msg_05.gif) repeat-x; padding-top:3px;'>\" + this.caption + \"</td>\"\n ");
108 m_Script.Append("str += \"<td width='23px'><img src='images/msg/msg_07.gif' id='btSysClose' title='关闭' style='cursor:hand;' /></td>\"\n ");
109 m_Script.Append("str += \"</tr>\"\n ");
110 m_Script.Append("str += \"</table>\"\n ");
111 m_Script.Append("str += \"<table width='100%' border='0' cellspacing='0' cellpadding='0'>\"\n ");
112 m_Script.Append("str += \"<tr>\"\n ");
113 m_Script.Append("str += \"<td width='5px' rowspan='2' background='images/msg/msg_09.gif'></td>\"\n ");
114 m_Script.Append("str += \"<td width='\"+(this.width-10)+\"px' height=\"+(this.height-54)+\" background='images/msg/bg_01.gif' style='line-height:16px; color:#191CCB;'><div style='margin:10px;font-size:12px;cursor:hand;'>\"+ this.message + \"</div></td>\"\n ");
115 m_Script.Append("str += \"<td width='5px' rowspan='2' background='images/msg/msg_15.gif'></td>\"\n ");
116 m_Script.Append("str += \"</tr>\"\n ");
117 m_Script.Append("str += \"<tr>\"\n ");
118 m_Script.Append("str += \"<td height='24' background='images/msg/bg_02.gif' > <a id='btnMessage'></a></td>\"\n ");
119 m_Script.Append("str += \"</tr>\"\n ");
120 m_Script.Append("str += \"</table>\"\n ");
121 m_Script.Append("str += \"<table width='\"+this.width+\"px' ' border='0' cellspacing='0' cellpadding='0'>\"\n ");
122 m_Script.Append("str += \"<tr><td height='8px' style='width: 12px; background: url(images/msg/left.jpg)'>\"\n ");
123 m_Script.Append("str += \" <td height='8px' style='width:\"+(this.width-22)+\"px; background: url(images/msg/middle.jpg)'>\"\n ");
124 m_Script.Append("str += \"<td height='8px' style='width: 10px; background: url(images/msg/right.jpg)'>\"\n ");
125 m_Script.Append("str += \"</tr>\"\n ");
126 m_Script.Append("str += \"</table>\"\n ");
127 m_Script.Append("str += \"</div>\"\n ");
128 m_Script.Append("alert(str); oPopup.document.body.innerHTML = str; \n ");
129 m_Script.Append("this.offset = 0; \n ");
130 m_Script.Append("var me = this; \n ");
131 m_Script.Append("oPopup.document.body.onmouseover = function(){me.pause=true;}\n ");
132 m_Script.Append("oPopup.document.body.onmouseout = function(){me.pause=false;}\n ");
133 m_Script.Append("var fun = function(){ \n ");
134 m_Script.Append("var x = me.left; \n ");
135 m_Script.Append("var y = 0; \n ");
136 m_Script.Append("var width = me.width; \n ");
137 m_Script.Append("var height = me.height; \n ");
138 m_Script.Append("if(me.offset>me.height){ \n ");
139 m_Script.Append("height = me.height; \n ");
140 m_Script.Append("} else { \n ");
141 m_Script.Append("height = me.offset; \n ");
142 m_Script.Append("} \n ");
143 m_Script.Append("y = me.bottom - me.offset; \n ");
144 m_Script.Append("if(y<=me.top){ \n ");
145 m_Script.Append("me.timeout--; \n ");
146 m_Script.Append("if(me.timeout==0){ \n ");
147 m_Script.Append("window.clearInterval(me.timer); \n ");
148 m_Script.Append("if(me.autoHide){\n ");
149 m_Script.Append("me.hide(); \n ");
150 m_Script.Append("}\n ");
151 m_Script.Append("} \n ");
152 m_Script.Append("} else { \n ");
153 m_Script.Append("me.offset = me.offset + me.step; \n ");
154 m_Script.Append("} \n ");
155 m_Script.Append("me.Pop.show(x,y,width,height); \n ");
156 m_Script.Append("} \n ");
157 m_Script.Append("this.timer = window.setInterval(fun,this.speed) \n ");
158 m_Script.Append("var btClose = oPopup.document.getElementById(\"btSysClose\" ); \n ");
159 m_Script.Append("btClose.onclick = function(){ \n ");
160 m_Script.Append("me.close = true;\n ");
161 m_Script.Append("me.hide(); \n ");
162 m_Script.Append("} \n ");
163 m_Script.Append("} \n ");
164 m_Script.Append("/* \n ");
165 m_Script.Append("** 设置速度方法 \n ");
166 m_Script.Append("**/ \n ");
167 m_Script.Append("CLASS_MSN_MESSAGE.prototype.speed = function(s){ \n ");
168 m_Script.Append("var t = 20; \n ");
169 m_Script.Append("try { \n ");
170 m_Script.Append("t = praseInt(s); \n ");
171 m_Script.Append("} catch(e){} \n ");
172 m_Script.Append("this.speed = t; \n ");
173 m_Script.Append("} \n ");
174 m_Script.Append("/* \n ");
175 m_Script.Append("** 设置步长方法 \n ");
176 m_Script.Append("**/ \n ");
177 m_Script.Append("CLASS_MSN_MESSAGE.prototype.step = function(s){ \n ");
178 m_Script.Append("var t = 1; \n ");
179 m_Script.Append("try { \n ");
180 m_Script.Append("t = praseInt(s); \n ");
181 m_Script.Append("} catch(e){} \n ");
182 m_Script.Append("this.step = t; \n ");
183 m_Script.Append("} \n ");
184 m_Script.Append("CLASS_MSN_MESSAGE.prototype.rect = function(left,right,top,bottom){ \n ");
185 m_Script.Append("try { \n ");
186 m_Script.Append("this.left = left !=null?left:this.right-this.width; \n ");
187 m_Script.Append("this.right = right !=null?right:this.left +this.width; \n ");
188 m_Script.Append("this.bottom = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height; \n ");
189 m_Script.Append("this.top = top !=null?top:this.bottom - this.height; \n ");
190 m_Script.Append("} catch(e){} \n ");
191 m_Script.Append("} \n ");
192 m_Script.Append("function NavigateUrl(url){ parent.parent['Main'].location=url;} \n ");
193 m_Script.Append("</SCRIPT> \n ");
194 #endregion Script
195 HttpContext.Current.Response.Write(m_Script.ToString());
196 }
197 #endregion
198
199 #region 缓慢的显示
200 /// <summary>
201 /// 缓慢的显示。
202 /// <param name="Content">弹出框显示的内容</param>
203 /// <param name="Height">弹出框的高度</param>
204 /// <param name="Title">弹出框的标题</param>
205 /// <param name="Width">弹出框的宽度</param>
206 /// </summary>
207 public void Slowly(int Width, int Height, string Title, string Content)
208 {
209 string Message = "<script language='" + "javascript" + "' type='" + "text/javascript" + "'> var MSG1 = new CLASS_MSN_MESSAGE('" + "task" + "','" + Width + "','" + Height + "','" + "上级安排任务提示:" + "',\"" + Content + "\",'" + "" + "');" +
210 " MSG1.rect(null,null,null,screen.height); " +
211 " MSG1.show(); </script>"
212 HttpContext.Current.Response.Write(Message);
213 }
214
215 /// <summary>
216 /// 缓慢的显示。
217 /// <param name="Title">弹出框的标题</param>
218 /// <param name="Width">弹出框的宽度</param>
219 /// </summary>
220 public void Slowly(string Title, string Content)
221 {
222 Slowly(258, 160, Title, Content);
223 }
224 #endregion
225
226 #region 快速的显示
227 /// <summary>
228 /// 快速的显示
229 /// <param name="Content">弹出框显示的内容</param>
230 /// <param name="Height">弹出框的高度</param>
231 /// <param name="Title">弹出框的标题</param>
232 /// <param name="Width">弹出框的宽度</param>
233 /// </summary>
234 public void Quickly(int Width, int Height, string Title, string Content)
235 {
236 string Message = "<script language='" + "javascript" + "' type='" + "text/javascript" + "'> var MSG1 = new CLASS_MSN_MESSAGE('" + "task" + "','" + Width + "','" + Height + "','" + "上级安排任务提示:" + "',\"" + Content + "\",'" + "" + "');" +
237 " MSG1.rect(null,null,null,screen.height-35); " +
238 "MSG1.speed = 20; " +
239 " MSG1.step = 5; " +
240 " MSG1.show(); </script>";
241 HttpContext.Current.Response.Write(Message);
242 }
243
244 /// <summary>
245 /// 快速的显示
246 /// <param name="Title">弹出框的标题</param>
247 /// <param name="Width">弹出框的宽度</param>
248 /// </summary>
249 public void Quickly(string Title, string Content)
250 {
251 Quickly(258, 160, Title, Content);
252 }
253 #endregion
254
255 #region 调用静态的操作
256 /// <summary>
257 /// 调用显示的属性。
258 /// </summary>
259 /// <returns></returns>
260 public static PopupMessage Display
261 {
262 get
263 {
264 return new PopupMessage();
265 }
266 }
267 #endregion
268 }
269 }
270
1 using System;
2 using System.Web;
3 using System.Collections.Generic;
4 using System.Text;
5
6 /****************************************
7 * 作者:wenjl
8 * 功能:使用该类,可以实现右下角的弹出界面。
9 * 日期:2008-10-26
10 * 版本:0.1
11 * **************************************/
12 namespace PopupMessage
13 {
14 /// <summary>
15 /// 使用该类,可以实现右下角的弹出界面。
16 /// </summary>
17 public class PopupMessage
18 {
19 private StringBuilder m_Script;
20
21 #region PopupMessage构造函数。
22 /// <summary>
23 /// 构告出弹出界面的前台脚本。
24 /// </summary>
25 public PopupMessage()
26 {
27 m_Script = new StringBuilder();
28 #region Script
29 m_Script.Append("<SCRIPT language=\"JavaScript\" type=\"text/javascript\"> \n ");
30 // m_Script.Append("<!-- \n ");
31 m_Script.Append("function CLASS_MSN_MESSAGE(id,width,height,caption,message,target,action){ \n ");
32 m_Script.Append("this.id = id; \n ");
33 m_Script.Append("this.caption= caption; \n ");
34 m_Script.Append("this.message= message; \n ");
35 m_Script.Append("this.target = target; \n ");
36 m_Script.Append("this.action = action; \n ");
37 m_Script.Append("this.width = width; \n ");
38 m_Script.Append("this.height = height; \n ");
39 m_Script.Append("this.timeout= 2000; \n ");
40 m_Script.Append("this.speed = 20; \n ");
41 m_Script.Append("this.step = 1; \n ");
42 m_Script.Append("this.right = screen.width -1; \n ");
43 m_Script.Append("this.bottom = screen.height; \n ");
44 m_Script.Append("this.left = this.right - this.width; \n ");
45 m_Script.Append("this.top = this.bottom - this.height; \n ");
46 m_Script.Append("this.timer = 0; \n ");
47 m_Script.Append("this.pause = false;\n ");
48 m_Script.Append("this.close = false;\n ");
49 m_Script.Append("this.autoHide = true;\n ");
50 m_Script.Append("} \n ");
51 m_Script.Append("/* \n ");
52 m_Script.Append("* 隐藏消息方法 \n ");
53 m_Script.Append("*/ \n ");
54 m_Script.Append("CLASS_MSN_MESSAGE.prototype.hide = function(){ \n ");
55 m_Script.Append("if(this.onunload()){ \n ");
56 m_Script.Append("var offset = this.height>this.bottom-this.top?this.height:this.bottom-this.top; \n ");
57 m_Script.Append("var me = this; \n ");
58 m_Script.Append("if(this.timer>0){ \n ");
59 m_Script.Append("window.clearInterval(me.timer); \n ");
60 m_Script.Append("} \n ");
61 m_Script.Append("var fun = function(){ \n ");
62 m_Script.Append("if(me.pause==false||me.close){\n ");
63 m_Script.Append("var x = me.left; \n ");
64 m_Script.Append("var y = 0; \n ");
65 m_Script.Append("var width = me.width; \n ");
66 m_Script.Append("var height = 0; \n ");
67 m_Script.Append("if(me.offset>0){ \n ");
68 m_Script.Append("height = me.offset; \n ");
69 m_Script.Append("} \n ");
70 m_Script.Append("y = me.bottom - height; \n ");
71 m_Script.Append("if(y>=me.bottom){ \n ");
72 m_Script.Append("window.clearInterval(me.timer); \n ");
73 m_Script.Append("me.Pop.hide(); \n ");
74 m_Script.Append("} else { \n ");
75 m_Script.Append("me.offset = me.offset - me.step; \n ");
76 m_Script.Append("} \n ");
77 m_Script.Append("me.Pop.show(x,y,width,height); \n ");
78 m_Script.Append("} \n ");
79 m_Script.Append("} \n ");
80 m_Script.Append("this.timer = window.setInterval(fun,this.speed) \n ");
81 m_Script.Append("} \n ");
82 m_Script.Append("} \n ");
83 m_Script.Append("/* \n ");
84 m_Script.Append("* 消息卸载事件,可以重写 \n ");
85 m_Script.Append("*/ \n ");
86 m_Script.Append("CLASS_MSN_MESSAGE.prototype.onunload = function() { \n ");
87 m_Script.Append("return true; \n ");
88 m_Script.Append("} \n ");
89 m_Script.Append("/* \n ");
90 m_Script.Append("* 消息命令事件,要实现自己的连接,请重写它 \n ");
91 m_Script.Append("* \n ");
92 m_Script.Append("*/ \n ");
93 m_Script.Append("CLASS_MSN_MESSAGE.prototype.oncommand = function(){ \n ");
94 m_Script.Append("this.hide(); \n ");
95 m_Script.Append("} \n ");
96 m_Script.Append("/* \n ");
97 m_Script.Append("* 消息显示方法 \n ");
98 m_Script.Append("*/ \n ");
99 m_Script.Append("CLASS_MSN_MESSAGE.prototype.show = function(){ \n ");
100 m_Script.Append("var oPopup = window.createPopup(); /*IE5.5+ */ \n ");
101 m_Script.Append("this.Pop = oPopup; \n ");
102 m_Script.Append("var w = this.width; \n ");
103 m_Script.Append("var h = this.height; \n ");
104 m_Script.Append("var str = \"<div style='z-index: 99999;width:\" + w + \"px; height:\" + h + \"px;'>\" \n ");
105 m_Script.Append("str += \"<table width='\"+this.width+\"px' border='0' cellspacing='0' cellpadding='0'>\" \n ");
106 m_Script.Append("str += \"<tr><td width='36px' height=24><img src='images/msg/msg_03.gif' /></td>\" \n ");
107 m_Script.Append("str += \"<td style='font-size:12px; color:#FFF; font-weight:bold; line-height:20px; background:url(images/msg/msg_05.gif) repeat-x; padding-top:3px;'>\" + this.caption + \"</td>\"\n ");
108 m_Script.Append("str += \"<td width='23px'><img src='images/msg/msg_07.gif' id='btSysClose' title='关闭' style='cursor:hand;' /></td>\"\n ");
109 m_Script.Append("str += \"</tr>\"\n ");
110 m_Script.Append("str += \"</table>\"\n ");
111 m_Script.Append("str += \"<table width='100%' border='0' cellspacing='0' cellpadding='0'>\"\n ");
112 m_Script.Append("str += \"<tr>\"\n ");
113 m_Script.Append("str += \"<td width='5px' rowspan='2' background='images/msg/msg_09.gif'></td>\"\n ");
114 m_Script.Append("str += \"<td width='\"+(this.width-10)+\"px' height=\"+(this.height-54)+\" background='images/msg/bg_01.gif' style='line-height:16px; color:#191CCB;'><div style='margin:10px;font-size:12px;cursor:hand;'>\"+ this.message + \"</div></td>\"\n ");
115 m_Script.Append("str += \"<td width='5px' rowspan='2' background='images/msg/msg_15.gif'></td>\"\n ");
116 m_Script.Append("str += \"</tr>\"\n ");
117 m_Script.Append("str += \"<tr>\"\n ");
118 m_Script.Append("str += \"<td height='24' background='images/msg/bg_02.gif' > <a id='btnMessage'></a></td>\"\n ");
119 m_Script.Append("str += \"</tr>\"\n ");
120 m_Script.Append("str += \"</table>\"\n ");
121 m_Script.Append("str += \"<table width='\"+this.width+\"px' ' border='0' cellspacing='0' cellpadding='0'>\"\n ");
122 m_Script.Append("str += \"<tr><td height='8px' style='width: 12px; background: url(images/msg/left.jpg)'>\"\n ");
123 m_Script.Append("str += \" <td height='8px' style='width:\"+(this.width-22)+\"px; background: url(images/msg/middle.jpg)'>\"\n ");
124 m_Script.Append("str += \"<td height='8px' style='width: 10px; background: url(images/msg/right.jpg)'>\"\n ");
125 m_Script.Append("str += \"</tr>\"\n ");
126 m_Script.Append("str += \"</table>\"\n ");
127 m_Script.Append("str += \"</div>\"\n ");
128 m_Script.Append("alert(str); oPopup.document.body.innerHTML = str; \n ");
129 m_Script.Append("this.offset = 0; \n ");
130 m_Script.Append("var me = this; \n ");
131 m_Script.Append("oPopup.document.body.onmouseover = function(){me.pause=true;}\n ");
132 m_Script.Append("oPopup.document.body.onmouseout = function(){me.pause=false;}\n ");
133 m_Script.Append("var fun = function(){ \n ");
134 m_Script.Append("var x = me.left; \n ");
135 m_Script.Append("var y = 0; \n ");
136 m_Script.Append("var width = me.width; \n ");
137 m_Script.Append("var height = me.height; \n ");
138 m_Script.Append("if(me.offset>me.height){ \n ");
139 m_Script.Append("height = me.height; \n ");
140 m_Script.Append("} else { \n ");
141 m_Script.Append("height = me.offset; \n ");
142 m_Script.Append("} \n ");
143 m_Script.Append("y = me.bottom - me.offset; \n ");
144 m_Script.Append("if(y<=me.top){ \n ");
145 m_Script.Append("me.timeout--; \n ");
146 m_Script.Append("if(me.timeout==0){ \n ");
147 m_Script.Append("window.clearInterval(me.timer); \n ");
148 m_Script.Append("if(me.autoHide){\n ");
149 m_Script.Append("me.hide(); \n ");
150 m_Script.Append("}\n ");
151 m_Script.Append("} \n ");
152 m_Script.Append("} else { \n ");
153 m_Script.Append("me.offset = me.offset + me.step; \n ");
154 m_Script.Append("} \n ");
155 m_Script.Append("me.Pop.show(x,y,width,height); \n ");
156 m_Script.Append("} \n ");
157 m_Script.Append("this.timer = window.setInterval(fun,this.speed) \n ");
158 m_Script.Append("var btClose = oPopup.document.getElementById(\"btSysClose\" ); \n ");
159 m_Script.Append("btClose.onclick = function(){ \n ");
160 m_Script.Append("me.close = true;\n ");
161 m_Script.Append("me.hide(); \n ");
162 m_Script.Append("} \n ");
163 m_Script.Append("} \n ");
164 m_Script.Append("/* \n ");
165 m_Script.Append("** 设置速度方法 \n ");
166 m_Script.Append("**/ \n ");
167 m_Script.Append("CLASS_MSN_MESSAGE.prototype.speed = function(s){ \n ");
168 m_Script.Append("var t = 20; \n ");
169 m_Script.Append("try { \n ");
170 m_Script.Append("t = praseInt(s); \n ");
171 m_Script.Append("} catch(e){} \n ");
172 m_Script.Append("this.speed = t; \n ");
173 m_Script.Append("} \n ");
174 m_Script.Append("/* \n ");
175 m_Script.Append("** 设置步长方法 \n ");
176 m_Script.Append("**/ \n ");
177 m_Script.Append("CLASS_MSN_MESSAGE.prototype.step = function(s){ \n ");
178 m_Script.Append("var t = 1; \n ");
179 m_Script.Append("try { \n ");
180 m_Script.Append("t = praseInt(s); \n ");
181 m_Script.Append("} catch(e){} \n ");
182 m_Script.Append("this.step = t; \n ");
183 m_Script.Append("} \n ");
184 m_Script.Append("CLASS_MSN_MESSAGE.prototype.rect = function(left,right,top,bottom){ \n ");
185 m_Script.Append("try { \n ");
186 m_Script.Append("this.left = left !=null?left:this.right-this.width; \n ");
187 m_Script.Append("this.right = right !=null?right:this.left +this.width; \n ");
188 m_Script.Append("this.bottom = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height; \n ");
189 m_Script.Append("this.top = top !=null?top:this.bottom - this.height; \n ");
190 m_Script.Append("} catch(e){} \n ");
191 m_Script.Append("} \n ");
192 m_Script.Append("function NavigateUrl(url){ parent.parent['Main'].location=url;} \n ");
193 m_Script.Append("</SCRIPT> \n ");
194 #endregion Script
195 HttpContext.Current.Response.Write(m_Script.ToString());
196 }
197 #endregion
198
199 #region 缓慢的显示
200 /// <summary>
201 /// 缓慢的显示。
202 /// <param name="Content">弹出框显示的内容</param>
203 /// <param name="Height">弹出框的高度</param>
204 /// <param name="Title">弹出框的标题</param>
205 /// <param name="Width">弹出框的宽度</param>
206 /// </summary>
207 public void Slowly(int Width, int Height, string Title, string Content)
208 {
209 string Message = "<script language='" + "javascript" + "' type='" + "text/javascript" + "'> var MSG1 = new CLASS_MSN_MESSAGE('" + "task" + "','" + Width + "','" + Height + "','" + "上级安排任务提示:" + "',\"" + Content + "\",'" + "" + "');" +
210 " MSG1.rect(null,null,null,screen.height); " +
211 " MSG1.show(); </script>"
212 HttpContext.Current.Response.Write(Message);
213 }
214
215 /// <summary>
216 /// 缓慢的显示。
217 /// <param name="Title">弹出框的标题</param>
218 /// <param name="Width">弹出框的宽度</param>
219 /// </summary>
220 public void Slowly(string Title, string Content)
221 {
222 Slowly(258, 160, Title, Content);
223 }
224 #endregion
225
226 #region 快速的显示
227 /// <summary>
228 /// 快速的显示
229 /// <param name="Content">弹出框显示的内容</param>
230 /// <param name="Height">弹出框的高度</param>
231 /// <param name="Title">弹出框的标题</param>
232 /// <param name="Width">弹出框的宽度</param>
233 /// </summary>
234 public void Quickly(int Width, int Height, string Title, string Content)
235 {
236 string Message = "<script language='" + "javascript" + "' type='" + "text/javascript" + "'> var MSG1 = new CLASS_MSN_MESSAGE('" + "task" + "','" + Width + "','" + Height + "','" + "上级安排任务提示:" + "',\"" + Content + "\",'" + "" + "');" +
237 " MSG1.rect(null,null,null,screen.height-35); " +
238 "MSG1.speed = 20; " +
239 " MSG1.step = 5; " +
240 " MSG1.show(); </script>";
241 HttpContext.Current.Response.Write(Message);
242 }
243
244 /// <summary>
245 /// 快速的显示
246 /// <param name="Title">弹出框的标题</param>
247 /// <param name="Width">弹出框的宽度</param>
248 /// </summary>
249 public void Quickly(string Title, string Content)
250 {
251 Quickly(258, 160, Title, Content);
252 }
253 #endregion
254
255 #region 调用静态的操作
256 /// <summary>
257 /// 调用显示的属性。
258 /// </summary>
259 /// <returns></returns>
260 public static PopupMessage Display
261 {
262 get
263 {
264 return new PopupMessage();
265 }
266 }
267 #endregion
268 }
269 }
270
使用方法:
Code
PopupMessage.PopupMessage message = new PopupMessage.PopupMessage();
string SongPath = System.Configuration.ConfigurationManager.AppSettings["SongPath"].ToString();
string result = "<bgsound src='" + SongPath + "' loop=2/><a id='btnNewMessage' style='text-decoration:none;cursor:hand;'>您好!目前有111等 222个待办事项,请点击查看!</a>";
string aa = "SaleManager/OrderList.aspx";
result = result + "<br/> <bgsound src='" + SongPath + "' loop=2/>" +
"<a id='btnaNewMessage' style='text-decoration:none;cursor:hand;' onclick='parent.NavigateUrl(\\\"" + aa + "\\\");'>您好!目前有" + "sss" + "等" + "11" + "个待办事项,请点击查看!</a>";
message.Slowly(258, 160, "待办事项", result);
PopupMessage.PopupMessage message = new PopupMessage.PopupMessage();
string SongPath = System.Configuration.ConfigurationManager.AppSettings["SongPath"].ToString();
string result = "<bgsound src='" + SongPath + "' loop=2/><a id='btnNewMessage' style='text-decoration:none;cursor:hand;'>您好!目前有111等 222个待办事项,请点击查看!</a>";
string aa = "SaleManager/OrderList.aspx";
result = result + "<br/> <bgsound src='" + SongPath + "' loop=2/>" +
"<a id='btnaNewMessage' style='text-decoration:none;cursor:hand;' onclick='parent.NavigateUrl(\\\"" + aa + "\\\");'>您好!目前有" + "sss" + "等" + "11" + "个待办事项,请点击查看!</a>";
message.Slowly(258, 160, "待办事项", result);
这里面需要注意的是\的问题,因为在跳转的时候,要注意方法内的参数是否可以使用.
代码下载/Files/wenjl520/PopupMessage.rar