定时弹出提示信息 不刷新页面。

  


var strHtml,countHtml;
var oPopup;
var secs=5;//第一次提示时间秒  
/*************************/
//定义XMLHttp实例  
var xmlHttp;  
function createXMLHttpRequest()
{  
// var xx = document.getElementById("isNotes");
// xx = xx.value;
// if(xx == "0")
// {
//  return;
// }
    //开始初始化XMLHttpRequest对象  
      if(window.ActiveXObject)
      {  
        //IE浏览器  
          xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  
      }
      else if(window.XMLHttpRequest)
      {  
        //Mozilla浏览器  
          xmlHttp = new XMLHttpRequest();  
      }  
    if(xmlHttp)
    {  
      //设置请求地址  
      xmlHttp.open("GET","message.aspx?cmd=get",true);  
      xmlHttp.onreadystatechange=setState;//设置回调函数  
      xmlHttp.send(null);  
    }  
}  
//回调函数  
function setState(){  
  if(xmlHttp.readyState == 4){  
  if(xmlHttp.status == 200){  
  parseResults(xmlHttp.responseXML)  
  }  
  }  
}  
/*处理XML*/  
function parseResults(xmlDOM) {  
try
{  
    var root = xmlDOM.documentElement;  
    var info = root.getElementsByTagName('aa');  
    var out = "",out_msg="";  
    var message = null;  
    var current = null;  
    var id="",msgid="";
    var title="";
    var createdate = "",usertype="",olstates=""; 
    var counts = 0;
    counts = info.length; 
    if(counts > 0)
    {
        message = info[0];  
         usertype = message.getElementsByTagName("wy")[0].childNodes[0].nodeValue.replace(' ','');
        if(usertype.indexOf("1") == "0")
        {
          for(var i=0;i<counts;i++)
          {   
                message = info[i];  // οnclick='parent.showInfo("+id+","+0+") '
                id = message.getElementsByTagName("no")[0].childNodes[0].nodeValue;         
                msgid = message.getElementsByTagName("msg")[0].childNodes[0].nodeValue; 
                var usertype1 = message.getElementsByTagName("type")[0].childNodes[0].nodeValue; 
                if(usertype1.indexOf("1") == "0" || usertype1.indexOf("3") == "0")
                {
                out=out+("<p style=\"font-size:12px; color: red; face: Tahoma\" title='新处理\n"
                +"'"+" >您有"  
                +id +" 条需要处理的记录!"
                +"</p > <BR>");
                  out_msg=out_msg+("<p style=\"font-size:12px; color: red; face: Tahoma\" title='新留言\n"
                +"'"+" >您有"  
                +msgid +" 条新留言!"
                +"</p > <BR>"); 
                }else
                {
                  out=out+("<p style=\"font-size:12px; color: red; face: Tahoma\" title='新处理\n"
                +"'"+" >您有"  
                +id +" 条未查看!"
                +"</p > <BR>");
                  out_msg=out_msg+("<p style=\"font-size:12px; color: red; face: Tahoma\" title='新留言\n"
                +"'"+" >您有"  
                +msgid +" 条新留言!"
                +"</p > <BR>");
                }
          }
              if(id > "0" || msgid > "0")
          {
              strHtml =  out;  
              countHtml = "-新信息";// id +"条新信息!";
             // popmsg(out,counts); 
              var msg =new PopBubble(countHtml,strHtml,"",out_msg);
              msg.show();
          } 
      }
    }
  }
  catch(exception)
  {  
     //alert("出错了!"+exception);  
  }  
}  
  
 
  
 function WinOpen(op) {
   mesg=open(op,"DisplayWindow","");//toolbar=yes,,menubar=yes,location=yes,scrollbars=yes resizable=no
 }
/*
 构造函数,来初始化相应的属性
*/
function PopBubble(caption,content,see,out_msg){ 
      
    this.content  = content;     
    this.caption= caption;
    this.seemsg=out_msg;
    this.see= see;      
    this.width= 250;   
    this.height = 200;       
    this.timeout= 150;        
    this.speed    = 15;     
    this.step    = 2;    
    this.right    = screen.width -1; 
    this.bottom = screen.height;   
    this.left = this.right - this.width;  
    this.top= this.bottom - this.height;  
    this.timer    = 0;
    this.pause    = false;
    this.close    = false;
    this.autoHide    = true;

 
/* 
   退宿弹出窗口的方法 
 */ 
PopBubble.prototype.hide = function(){ 
        var offset  = this.height>this.bottom-this.top?this.height:this.bottom-this.top;
        var obj  = this; 
   
        if(this.timer>0){  
            window.clearInterval(obj.timer); 
        } 
 
        var fun = function(){ 
            if(obj.pause==false||obj.close){
                var x  = obj.left;
                var y  = 0;
                var width = obj.width;
                var height = 0;
    
                if(obj.offset>0){
                    height = obj.offset;
                }
                y  = obj.bottom - height;
                if(y>=obj.bottom){
                    window.clearInterval(obj.timer); 
                    obj.Pop.hide(); 
                } else {
                    obj.offset = obj.offset - obj.step; 
                }
                obj.Pop.show(x,y,width,height);   
            }            
        }     
        this.timer = window.setInterval(fun,this.speed)    

  
/*
    实现查看超链接 
  
 */ 
PopBubble.prototype.oncommand = function(types)

   showInfo(types);
   //showInfo2();
    this.close = true;
    this.hide(); 

 
/* 
     显示窗口中的div并弹出窗口方法
 */ 
 
PopBubble.prototype.show = function(){
   
   oPopup = window.createPopup();   
    this.Pop = oPopup; 
    var w = this.width; 
    var h = this.height; 
 
    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: #DAED9B'>" 
        str += "<TABLE style='BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid' cellSpacing=0 cellPadding=0 width='100%' bgColor=#EEF7CC border=0>" 
        str += "<TR>" 
        str += "<TD style='FONT-SIZE: 12px;COLOR: #0f2c8c' width=30 height=24></TD>" 
        str += "<TD style='PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #1f336b; PADDING-TOP: 4px' vAlign=center width='100%'>" + this.caption + "</TD>" 
        str+=" <td style='PADDING-right: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #1f336b; PADDING-TOP: 4px' vAlign=right ><a href=\"#\" οnclick=\"parent.pophide();\" style=\"font-size:12px; width:30px; color: red; face: Tahoma\">关闭</a></td>"
        str += "</TR>" 
        str += "<TR>" 
        str += "<TD style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px' colSpan=3 height=" + (h-28) + ">" 
        str += "<DIV style='BORDER-RIGHT: #b9c9ef 1px solid; PADDING-RIGHT: 8px; BORDER-TOP: #7AA14E 1px solid; PADDING-LEFT: 8px; FONT-SIZE: 12px; PADDING-BOTTOM: 8px; BORDER-LEFT: #7AA14E 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 8px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%'>"
        + this.see + "<BR><BR>"         
        str += "<DIV style='WORD-BREAK: break-all;height:20px;' align=left><A href='#' height='20px'  hidefocus=true id='btCommand'><FONT color=#ff0000>" + this.content + "</FONT></A>"
        str += "</DIV>"      
        str += "<DIV style='WORD-BREAK: break-all;height:20px;' align=left><A href='#'  height='20px' hidefocus=true id='btCommand_msg'><FONT color=#ff0000>" + this.seemsg + "</FONT></A>"
        str += "</DIV> "
//        str += "</DIV>" 
        str += "</TD>" 
        str += "</TR>" 
        
        str += "</TABLE>" 
        str += "</DIV>" 
    oPopup.document.body.innerHTML = str;    
   
 
    this.offset  = 0;
    var obj  = this; 
    oPopup.document.body.onmouseover = function(){obj.pause=true;}
    oPopup.document.body.onmouseout = function(){obj.pause=false;}

    var fun = function(){   
        var x  = obj.left;
        var y  = 0;  
        var width    = obj.width;   
        var height    = obj.height;  
   
            if(obj.offset>obj.height){     
                height = obj.height;
            } else {   
                height = obj.offset;  
            }    
        y  = obj.bottom - obj.offset;
        if(y<=obj.top){
             obj.timeout--;
             if(obj.timeout==0){
                window.clearInterval(obj.timer); 
                if(obj.autoHide){
                    obj.hide();
                }
            }
        }
  else {
            obj.offset = obj.offset + obj.step;
        }
        obj.Pop.show(x,y,width,height);   
 
    } 
    this.timer = window.setInterval(fun,this.speed)     
    var btCommand = oPopup.document.getElementById("btCommand"); 
    btCommand.onclick = function(){ 
        obj.oncommand('olno'); 
    }   
    var btCommand_msg = oPopup.document.getElementById("btCommand_msg"); 
    btCommand_msg.onclick = function(){ 
        obj.oncommand('msg'); 
    }   
}  
 
PopBubble.prototype.rect = function(left,right,top,bottom){
    try {
        this.left= this.right-this.width;
        this.right=this.left +this.width;
        this.bottom  = screen.height;
        this.top = this.bottom - this.height;
    } catch(e){}
}
//createXMLHttpRequest();
 
  function checkServer(secs)
  {  
    for(i=1;i<=secs;i++)
    {  
      window.setTimeout("update(" + i + ")", i * 1000);  
    }  
  }  
 
  function update(num)
   {  
    if(num == secs)
     {  
      createXMLHttpRequest();  
      secs=1*120;//提示时间秒  
      for(i=1;i<=secs;i++)
      {  
        window.setTimeout("update(" + i + ")", i * 1000);  
      }  
    }  
    else
    {  
      printnr = secs-num;  
    }  
  }  
   function pophide()
   {  
    oPopup.hide();  
   } 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值