ActiveX提示信息插件


 

當我們開發web后台管理系統時經常會遇到提示用戶信息的功能,我們都知道由於瀏覽器的沙箱隔離問題我們無法直接操作系統本地資源,我們可以利用ActiveX IE瀏覽器插件來實現這個功能。這里的源碼主要做了右下角提示窗體顯示的的封裝,關於ActiveX插件安全性方面沒有做,你可以繼續優化這個插件。

該插件可以顯示不同類型背景的信息,還有提示音,可以設置顯示提示信息窗口最大數量。

下面代碼是公開給js調用的方法。

 1         /// <summary>
 2         /// 顯示提示信息
 3         /// </summary>
 4         /// <param name="title">標題</param>
 5         /// <param name="text">內容</param>
 6         /// <param name="messsageType">信息類型</param>
 7         /// <param name="customAlertBackColor">自定義信息背景html顏色</param>
 8         /// <param name="customAlertTextColor">自定義信息文本html顏色</param>
 9         public void ShowAlert(string title, string text, string messsageType, string customAlertBackColor, string customAlertTextColor)
10         {
11             try
12             {
13                 if (!DesktopAlert.Notify.Visible)
14                     DesktopAlert.ShowNotify();
15 
16                 Color? backColor = null;
17                 if (!String.IsNullOrWhiteSpace(customAlertBackColor))
18                     backColor = ColorTranslator.FromHtml(customAlertBackColor.Trim());
19 
20                 Color? textColor = null;
21                 if (!String.IsNullOrWhiteSpace(customAlertTextColor))
22                     textColor = ColorTranslator.FromHtml(customAlertTextColor.Trim());
23 
24                 DesktopAlert.MessageType type = (DesktopAlert.MessageType)Enum.Parse(typeof(DesktopAlert.MessageType), messsageType);
25                 DesktopAlert.ShowAlert(title, text, type, backColor, textColor);
26             }
27             catch
28             {
29 
30             }
31         }
32 
33         /// <summary>
34         /// 關閉通知欄
35         /// </summary>
36         public void CloseNotify()
37         {
38             try
39             {
40                 DesktopAlert.HideNotify();
41             }
42             catch
43             {
44 
45             }
46         }

 插件用法:

源碼下載地址:ActiveX提示信息插件.zip


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM