封装一个Ext消息提示框,显示几秒后自动消失
封了一装个Ext消息提示~提示信息显示秒后就自显消失。框几
css代显,
view plaincopy to clipboardprint?
1..msg .x-box-mc {
2.font-size:14px;
3.}
4.#msg-div {
5. position:absolute; 6. left:650px;
7. top:410px;
8. width:600px;
9. z-index:20000;
10.}
11..msg-close{ 12.width:10px; height:10px; position:absolute; top:1px; right:10px;cursor:hand;
13.}
14..msg-h3 {
15.font-size:13px;
16. color:#2870b2;
17. font-weight:bold; 18. margin:10px 0;
19.}
js代显,
view plaincopy to clipboardprint?
1./**
2. *信息提示~显示后迅速消失框 3. */
4.Ext.QuickMsg = function(){
5. var msgCt; 6.
7. function createBox(t, s,isClose){
8. var html = new Array();
9.
10. html.push('
');
11. html.push('
');
13. html.push('
');
14. if(t){
15. html.push('
'); 16. html.push(t);
17. html.push('
');
18. }
19. if(isClose){
20. html.push('
'); 21. }
22. html.push(s);
23. html.push('
');
24. html.push('
');
25. html.push('
');
26. return html.join('');
27. }
28. return {
29. /**
30. * 显示信息
31. * title:显显
32. * msg:提示信息
33. * time,显示显显~超显后自显消失
34. * alignEl,显显到显显象的左下角
35. * offsets[Array],向偏移像素~比如,横[200,0]显显右移200个像素
36. * positon,显画
37. * animate[boolean],是否显显显启画
38. * isClose[boolean],是否可显显
39. */
40. show : function(title, msg, width, time, alignEl, offsets, position,animate,isClose){
41. width = width?width:'250px';
42. time = time?time:2;
43. alignEl = alignEl?alignEl:document;
44. //alert(alignEl.id);
45. position = position?position:'t-t';
46. animate = animate?animate:false;
47. this.close();
48. if(!msgCt){
49. msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
50. msgCt.setWidth(width);
51. }
52. //采用默显显画将div的最中央显显到alignEl的左下角,并右移200个象素,且不能超出口窗
53. msgCt.alignTo(alignEl, position,offsets,animate); 54. var m = Ext.DomHelper.append(msgCt, {html:createBox(title, msg,isClose)}, true);
55. m.slideIn('t').pause(time).ghost("t", {remove:true});//元素上滑入效果从,可不显显用下参数
同
56. },
57.
58. //提示信息
59. alert : function(msg,field,alignEl,width){
60. width = width?width:'150px';
61. var html = '
'+msg+'';
62. this.show('',html,'150px',2,field,[120,0],'t-t',true,false);
63. },
64.
65. close: function(){ 66. var div = document.getElementById('msg-div'); 67. if(div){
68. div.style.display = 'none';
69. }
70. msgCt = '';
71. }
72. };
73.}();
显用示例1,显显提示
显示效果,
显用示例2,更显显的效果
view plaincopy to clipboardprint?
1.var s = "";
2. s += '
';
3. s += '';
4. s += ' 姓名 | ';
5. s += ' 年显 | ';
6. s += ' 性显 | ';
7. s += '
';
8. s += '';
9. s += ' 显三 | ';
10. s += ' 19 | ';
11. s += ' 男 | ';
12. s += '
';
13. s += '';
14. s += ' 李四 | ';
15. s += ' 30 | ';
16. s += ' 女 | ';
17. s += '
';
18. s += '
';
19.
20. Ext.QuickMsg.show('人显显显信息', s,'600px',2,Ext.get('tog'),[200,0],'t-t',true,true); 21.