网站公告列表

  没有公告

加入收藏
设为首页
在线投稿

您现在的位置: IT知识网 >> IT知识 >> 维修维护 >> 其它外设维护维修 >> 文章正文

 

  [组图]Web的桌面提醒(Popup,类似msn,outlook等的信息提示)         

Web的桌面提醒(Popup,类似msn,outlook等的信息提示)
作者:佚名 文章来源:不详 点击数: 更新时间:2006-12-6 1:07:41
    Web的桌面提醒(Popup,类似msn,outlook等的信息提示)
    Web的桌面提醒(Popup,类似msn,outlook等的信息提示)    昨晚加班,无意找到一些类似msn,outlook等的信息提示的资料,今天把它整理了一下,然后自己测试通过,先分享出来,如果大伙在发送邮件或需要弹出信息对话框时,可以做个参考,也希望这段代码能越来越好,大家多提意见。
    1.建立PopupManager.js,代码如下
    // 队列
    function Queue()
    {
     var items = new Array();
     var first = 0;
     var count = 0;
     // 队列大小
     this.Count = function()
     {
     return count;
     } ;
     // 取队列头/尾
     this.Peek = function(last)
     {
     var result = null;
     if (count > 0)
     {
     if (null != last && true == last)
     result = items[first + (count - 1)];
     else
     result = items[first];
     }
     return result;
     };
     // 入列
     this.Enqueue = function(x)
     {
     items[first + count] = x;
     count++;
     return x;
     };
    
     // 出列
     this.Dequeue = function()
     {
     var result = null;
     if (count > 0)
     {
     result = items[first];
     delete items[first];
     first++;
     count--;
     }
     return result;
     };
    }
    var newlineRegExp = new RegExp("(\r\n|\n|\r)", "g");
    function NewlineReplace(str)
    {
     result = "";
     if (str != null)
     result = str.replace(newlineRegExp, "
");
     return result;
    }
    
    var entityList = new Array();
    entityList["<"] = "<";
    entityList["\uff1c"] = "<";
    entityList[">"] = ">";
    entityList["\uff1e"] = ">";
    entityList["&"] = "&";
    entityList["\uff06"] = "&";
    entityList["\""] = """;
    entityList["\uff02"] = """;
    
    function EntityReplace(str)
    {
     var result = "";
     if (str != null)
     {
     var len = str.length;
     var i = 0;
     while (i < len)
     {
     var j = i;
     var e = entityList[str.charAt(j)];
     while (j < len && null == e)
     {
     j++;
     e = entityList[str.charAt(j)];
     }
     result += str.substr(i, j - i);
     if (e != null)
     {
     result += e;
     j++;
     }
     i = j;
     }
     }
     return result;
    }
    
    function GetPopupCssText()
    {
     var styles = document.styleSheets;
     var csstext = "";
     for(var i=0; i     {
     if (styles[i].id == "popupmanager")
     csstext += styles[i].cssText;
     }
     return csstext;
    }
    
    function PopupWin(winID)
    {
     this.Win = document.getElementById(winID);
     this.Menu = document.getElementById(winID + "_Menu");
     this.Icon = document.getElementById(winID + "_Icon");
     this.MenuButton = document.getElementById(winID + "_MenuButton");
     this.CloseButton = document.getElementById(winID + "_CloseButton");
     this.Caption = document.getElementById(winID + "_Caption");
     this.CaptionText = document.getElementById(winID + "_CaptionText");
     this.Body = document.getElementById(winID + "_Body");
     this.BodyText = document.getElementById(winID + "_BodyText");
    }
    
    function Popup(winID, message, icon, title, func)
    {
     this.PostID;
     this.URL;
     this.Type = "Mail"; // Mail,Thread,Post,Message
     this.win = new PopupWin(winID);
     this.popup = null;
     this.popupMenu = null;
     this.PopupManager = null;
     this.showTime = null;
     this.func = func;
     this.isMouseOver = false;
     this.CreateBody = Popup_CreateBody;
     this.Close = Popup_Close;
     this.Hide = Popup_Hide;
     this.Show = Popup_Show;
     this.ShowTime = Popup_ShowTime;
     this.aspxl = this.CreateBody(message, icon, title);
    }
    
    function Popup_Close()
    {
     if (this.popup != null)
     this.popup.document.onmouseover = null;
     else
     this.win.Win.onmouseover = null;
    
     this.isMouseOver = false;
     this.ShowTime = function()
     {
     return 7;
     }
     this.Hide();
    }
    
    function Popup_Hide()
    {
     if (this.popup != null && this.popup.isOpen)
     {
     this.popup.hide();
     }
     this.popup = null;
    }
    
    function Popup_ShowTime()
    {
     var result = null;
     if (this.showTime != null)
     {
     var now = new Date();
     result = (now - this.showTime)/1000;
     }
     return result;
    }
    
    function OnClickClose_Popup()
    {
     var p = this.getAttribute("popup");
     p.Close();
    }
    
    function OnClickMenu_Popup()
    {
     var p = this.getAttribute("popup");
     if (p.popupMenu == null)
     {
     p.popupMenu = p.popup.document.parentWindow.createPopup();
     var d = p.popupMenu.document;
     var s = d.createStyleSheet();
     s.cssText = GetPopupCssText();
     var b = d.body;
     b.rightmargin = 0;
     b.leftmargin = 0;
     b.topmargin = 0;
     b.bottommargin = 0;
     b.innerHTML = p.win.Menu.outerHTML;
     b.style.cursor = "default";
 &nbs

[1] [2] [3] [4] 下一页

文章录入:wuyongjian    责任编辑:wuyongjian 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最 新 热 门
    相 关 文 章
    Cisco 2610B 的配置实例
    专用Cisco路由器的替代品
    专用Cisco路由器的替代品
    Cisco接入点Web界面认证
    利用路由器的Cisco IOS 
    HUB故障导致无法实行Web
    分析IEEE 802.11中g与b的
    详细讲解IEEE802.11b的特
    手把手教你设置无线路由
    通过路由器搭建对外的We
     
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    Copyright© ITZS.NET All Rights Reserved
    QQ:272895858   ICP备案编号:吉ICP备07000044号
    IT知识网 站长:博浪