当前位置:编程学习 > C#/ASP.NET >>

屏幕右下角消息提醒

我想做一个屏幕右下角消息提醒的功能,不是在浏览器中,不知道各位大虾谁有解决方案? --------------------编程问答-------------------- http://www.cnblogs.com/wangjun8868/archive/2009/06/30/1514151.html
参考 --------------------编程问答--------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Keywords" content="51windows.Net">
<META NAME="Author" CONTENT="haiwa">
<title>类似MSN提示的页面效果</title>
</head>

<body scroll=no>
看到右下角的提示了吗?如果没有看到,<button onclick=location.reload();>刷新</button>一下
<script language="JavaScript">
window.onload = getMsg;
window.onresize = resizeDiv;
window.onerror = function(){}
//短信提示使用(asilas添加)
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg()
{
  try{
  divTop = parseInt(document.getElementById("eMeng").style.top,10)
  divLeft = parseInt(document.getElementById("eMeng").style.left,10)
  divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10)
  divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10)
  docWidth = document.body.clientWidth;
  docHeight = document.body.clientHeight;
  document.getElementById("eMeng").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;// divHeight
  document.getElementById("eMeng").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth
  document.getElementById("eMeng").style.visibility="visible"
  objTimer = window.setInterval("moveDiv()",10)
  }
  catch(e){}
}

function resizeDiv()
{
  i+=1
  if(i>500) closeDiv()
  try{
  divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10)
  divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10)
  docWidth = document.body.clientWidth;
  docHeight = document.body.clientHeight;
  document.getElementById("eMeng").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10)
  document.getElementById("eMeng").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10)
  }
  catch(e){}
}

function moveDiv()
{
  try
  {
  if(parseInt(document.getElementById("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
  {
  window.clearInterval(objTimer)
  objTimer = window.setInterval("resizeDiv()",1)
  }
  divTop = parseInt(document.getElementById("eMeng").style.top,10)
  document.getElementById("eMeng").style.top = divTop - 1
  }
  catch(e){}
}
function closeDiv()
{
  document.getElementById('eMeng').style.visibility='hidden';
  if(objTimer) window.clearInterval(objTimer)
}
</script>
<DIV id=eMeng style="BORDER-RIGHT: #455690 1px solid; BORDER-TOP: #a6b4cf 1px solid; Z-INDEX:99999; LEFT: 0px; VISIBILITY: hidden; BORDER-LEFT: #a6b4cf 1px solid; WIDTH: 180px; BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 0px; HEIGHT: 116px; BACKGROUND-COLOR: #c9d3f3">
  <TABLE style="BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid" cellSpacing=0 cellPadding=0 width="100%" bgColor=#cfdef4 border=0>
  <TBODY>
    <TR>
      <TD style="FONT-SIZE: 12px; BACKGROUND-IMAGE: url(msgTopBg.gif); COLOR: #0f2c8c" width=30 height=24></TD>
      <TD style="FONT-WEIGHT: normal; FONT-SIZE: 12px; BACKGROUND-IMAGE: url(msgTopBg.gif); COLOR: #1f336b; PADDING-TOP: 4px;PADDING-left: 4px" vAlign=center width="100%"> 短消息提示:</TD>
      <TD style="BACKGROUND-IMAGE: url(msgTopBg.gif); PADDING-TOP: 2px;PADDING-right:2px" vAlign=center align=right width=19><span title=关闭 style="CURSOR: hand;color:red;font-size:12px;font-weight:bold;margin-right:4px;" onclick=closeDiv() >×</span><!-- <IMG title=关闭 style="CURSOR: hand" onclick=closeDiv() hspace=3 src="msgClose.jpg"> --></TD>
    </TR>
    <TR>
      <TD style="PADDING-RIGHT: 1px; BACKGROUND-IMAGE: url(1msgBottomBg.jpg); PADDING-BOTTOM: 1px" colSpan=3 height=90>
        <DIV style="BORDER-RIGHT: #b9c9ef 1px solid; PADDING-RIGHT: 13px; BORDER-TOP: #728eb8 1px solid; PADDING-LEFT: 13px; FONT-SIZE: 12px; PADDING-BOTTOM: 13px; BORDER-LEFT: #728eb8 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 18px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%">您有<font color=#FF0000>1</font>封新短消息<BR><BR>
        <DIV align=center style="word-break:break-all"><a href="javascript:alert('你好')"><font color=#FF0000>点击查看短信</font></a></DIV

        </DIV>
      </TD>
    </TR>
  </TBODY>
  </TABLE>
</DIV>
<p>查找更多代码,请访问:<a href="http://www.lanrentuku.com" target="_blank">懒人图库</a></p>
</body>
</html>


把上面代码保存为一个html,运行看看 --------------------编程问答-------------------- 通过定时器弹出提示窗口,很多OA有这种功能 
<script> 
function openWindow(win,winTitle,winWidth,winHeight) 
    { 
    var winleft=window.screen.width-winWidth-12; 
    var winTop=window.screen.height-winHeight-75; 
    window.open(win ,winTitle,'width='+ winWidth +'px,height='+ winHeight +'px,left='+ winleft +'px,top='+ winTop +'px,scrollbars=1,status=0'); 
    } 
    </script> 
    <script language="javascript" type="text/javascript" src="../js/Ajax.js"> </script> 
    <script language="javascript" type="text/javascript"> 
  function check(typeStr) 

var myurl="Tip.aspx?type="+typeStr; 
var MyWebSend=""; 
xmlHttp.open("POST",myurl,true); 
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
xmlHttp.onreadystatechange = ValidateCallBack; 
xmlHttp.send(MyWebSend); 

function checkNormal() 

  check('normal'); 
  window.setTimeout("checkNormal()",60000); 

function checkCalendar() 

    check('calendar'); 
    window.setTimeout("checkCalendar()",1200000); 

function ValidateCallBack() 

    if (xmlHttp.readyState == 4) 

      if (xmlHttp.status == 200) 
    { 
  var result=xmlHttp.responseText;  
        if(result.indexOf("Exist::")==0) 
        { 
            openWindow('popTip.aspx','smsWindows','430','220'); 
        } 

  else 
    { 
  

    } 

</script> 
</head> 
<body onload="checkNormal();checkCalendar();"> 

在popTop里绑定数据 
<script> 
    focus(); 
    TimeStart=30; 
function MyTimer() 

  if(TimeStart==0) 
      window.close(); 
  if(document.getElementById("TimeShow")) 
      document.getElementById("TimeShow").innerHTML=TimeStart; 
  TimeStart--; 
  var timer=setTimeout("MyTimer()",1000); 

http://topic.csdn.net/u/20090114/17/dc7fc2fc-2fe3-4c31-b570-98261aa1bdb8.html --------------------编程问答--------------------
引用 3 楼 wuyq11 的回复:
通过定时器弹出提示窗口,很多OA有这种功能
<script>
function openWindow(win,winTitle,winWidth,winHeight)
    {
    var winleft=window.screen.width-winWidth-12;
    var winTop=window.screen.height-winHeight-75;
    window.open(win ,winTitle,'width='+ winWidth +'px,height='+ winHeight +'px,left='+ winleft +'px,top='+ winTop +'px,scrollbars=1,status=0');
    }
    </script>

    <script language="javascript" type="text/javascript" src="../js/Ajax.js"> </script>
    <script language="javascript" type="text/javascript">
  function check(typeStr)
{
var myurl="Tip.aspx?type="+typeStr;
var MyWebSend="";
xmlHttp.open("POST",myurl,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = ValidateCallBack;
xmlHttp.send(MyWebSend);
}
function checkNormal()
{
  check('normal');
  window.setTimeout("checkNormal()",60000);
}
function checkCalendar()
{
    check('calendar');
    window.setTimeout("checkCalendar()",1200000);
}
function ValidateCallBack()
{
    if (xmlHttp.readyState == 4)
{
      if (xmlHttp.status == 200)
    {
  var result=xmlHttp.responseText; 
        if(result.indexOf("Exist::")==0)
        {
            openWindow('popTip.aspx','smsWindows','430','220');
        }
}
  else
    {
 
}
    }
}
</script>
</head>
<body onload="checkNormal();checkCalendar();">

在popTop里绑定数据
<script>
    focus();
    TimeStart=30;
function MyTimer()
{
  if(TimeStart==0)
      window.close();
  if(document.getElementById("TimeShow"))
      document.getElementById("TimeShow").innerHTML=TimeStart;
  TimeStart--;
  var timer=setTimeout("MyTimer()",1000);
}
http://topic.csdn.net/u/20090114/17/dc7fc2fc-2fe3-4c31-b570-98261aa1bdb8.html

OK --------------------编程问答-------------------- 都好,学习啦 --------------------编程问答-------------------- 学习啊!! --------------------编程问答--------------------
引用楼主 zhy821226 的回复:
我想做一个屏幕右下角消息提醒的功能,不是在浏览器中,不知道各位大虾谁有解决方案?


从一楼开始都是做在浏览器当中了。LZ是说的系统当中的吧。。。就像QQ来消息了。。 --------------------编程问答--------------------
引用 7 楼 xinsiyu2008 的回复:
引用楼主 zhy821226 的回复:
我想做一个屏幕右下角消息提醒的功能,不是在浏览器中,不知道各位大虾谁有解决方案?


从一楼开始都是做在浏览器当中了。LZ是说的系统当中的吧。。。就像QQ来消息了。。

那个是不可能的,JS的脚本没有这个权限的,当然用ACTIVEX控件之类的话那就是另外的问题了。 --------------------编程问答-------------------- 找了一个不知道有没有帮助。。。
http://www.cnblogs.com/xushen8314/archive/2008/07/29/1255752.html
LZ就没有说用JS实现

--------------------编程问答-------------------- 那样的话只有写应用程序了吧? --------------------编程问答-------------------- 上面说的一般都是窗体加载时就弹出来,有没有那种当有新消息时弹出来,有点像QQ在线提醒那种效果的 --------------------编程问答-------------------- 另外写一个窗体应用程序在你系统中调用... --------------------编程问答-------------------- 我想大家都理解错意思了吧.
他想实现有人浏览他的网站

在window桌面的右下角(不是网页的右下角)弹出QQ样的消息.

这需要编一个winform程序并安装在本地电脑上,并与网站之间进行沟通吧 --------------------编程问答-------------------- 学习 --------------------编程问答-------------------- 看看... --------------------编程问答-------------------- 强人,学习了。 --------------------编程问答-------------------- 有点像迅雷的感觉,强弹对话框 --------------------编程问答-------------------- OA一般会有这功能 正在做OA不过现在做得还是乱七八糟的 --------------------编程问答-------------------- mark --------------------编程问答--------------------
引用楼主 zhy821226 的回复:
我想做一个屏幕右下角消息提醒的功能,不是在浏览器中,不知道各位大虾谁有解决方案?

不是在浏览器中?是在哪里的啊? --------------------编程问答-------------------- 我这有一个类似flash的东西 是个广告,不知道怎么出现的,每次开机一段时间就会出现,而且不报毒的。。。。。有点像楼主的意思 --------------------编程问答-------------------- 马克。。。 --------------------编程问答-------------------- 收藏了。。。 --------------------编程问答-------------------- 我怎经写过的一个
http://blog.csdn.net/LCL_data/archive/2010/03/08/5356573.aspx --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 学习 --------------------编程问答-------------------- 学习了 --------------------编程问答-------------------- 做个记号! --------------------编程问答--------------------
引用 3 楼 wuyq11 的回复:
通过定时器弹出提示窗口,很多OA有这种功能 
<script> 
function openWindow(win,winTitle,winWidth,winHeight) 
  { 
  var winleft=window.screen.width-winWidth-12; 
  var winTop=window.screen.height-winHeight-75; 
  win……

学习一下啊 呵呵 --------------------编程问答-------------------- mark 正在学习中,留下以后备用 --------------------编程问答-------------------- 真不错 --------------------编程问答--------------------
引用 11 楼 liyuan_accp 的回复:
上面说的一般都是窗体加载时就弹出来,有没有那种当有新消息时弹出来,有点像QQ在线提醒那种效果的

function VIN()
{
    var NUM=Frame_Bottom.GetNum(document.getElementById("txtQuartersId").value,document.getElementById("txtDepId").value,document.getElementById("txtOrganId").value,document.getElementById("txtId").value).value;
    var NUMY=document.getElementById("Text1").value;
    if(NUM!=NUMY)
    {
        window.location.reload();
    }
    setTimeout("VIN()",30000);
}
用iframe 留一个隐藏帧,当满足条件时重新加载页面 弹出窗口 --------------------编程问答--------------------

<SCRIPT language=JavaScript> 
<!-- 
 
/**//* 
*    消息构造 
*/ 
function CLASS_MSN_MESSAGE(id,width,height,caption,title,message,target,action){ 
    this.id     = id; 
    this.title  = title; 
    this.caption= caption; 
    this.message= message; 
    this.target = target; 
    this.action = action; 
    this.width    = width?width:200; 
    this.height = height?height:120; 
    this.timeout= 150; 
    this.speed    = 20;
    this.step    = 1;
    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;

 
/**//* 
*    隐藏消息方法 
*/ 
CLASS_MSN_MESSAGE.prototype.hide = function(){ 
    if(this.onunload()){ 

        var offset  = this.height>this.bottom-this.top?this.height:this.bottom-this.top;
        var me  = this; 

        if(this.timer>0){  
            window.clearInterval(me.timer); 
        } 

        var fun = function(){ 
            if(me.pause==false||me.close){
                var x  = me.left;
                var y  = 0;
                var width = me.width;
                var height = 0;
                if(me.offset>0){
                    height = me.offset;
                }
    
                y  = me.bottom - height;
    
                if(y>=me.bottom){
                    window.clearInterval(me.timer); 
                    me.Pop.hide(); 
                } else {
                    me.offset = me.offset - me.step; 
                }
                me.Pop.show(x,y,width,height);   
            }            
        } 

        this.timer = window.setInterval(fun,this.speed)     
    } 

 
/**//* 
*    消息卸载事件,可以重写 
*/ 
CLASS_MSN_MESSAGE.prototype.onunload = function() { 
    return true; 

/**//* 
*    消息命令事件,要实现自己的连接,请重写它 

*/ 
CLASS_MSN_MESSAGE.prototype.oncommand = function(){ 
    //this.close = true;
    this.hide(); 
 window.open("http://www.makewing.com");
  
}
/**//* 
*    消息显示方法 
*/ 
CLASS_MSN_MESSAGE.prototype.show = function(){ 

    var oPopup = window.createPopup(); //IE5.5+ 
   
    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: #c9d3f3'>" 
        str += "<TABLE style='BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid' cellSpacing=0 cellPadding=0 width='100%' bgColor=#cfdef4 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: 2px; PADDING-TOP: 2px' vAlign=center align=right width=19>" 
        str += "<SPAN title=关闭 style='FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px' id='btSysClose' >×</SPAN></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: #728eb8 1px solid; PADDING-LEFT: 8px; FONT-SIZE: 12px; PADDING-BOTTOM: 8px; BORDER-LEFT: #728eb8 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 8px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%'>" + this.title + "<BR><BR>" 
        str += "<DIV style='WORD-BREAK: break-all' align=left><A href='javascript:void(0)' hidefocus=false id='btCommand'><FONT color=#ff0000>" + this.message + "</FONT></A> - <A href='http://www.makewing.com' hidefocus=false id='ommand'><FONT color=#ff0000>网页素材下载站</FONT></A></DIV>" 
        str += "</DIV>" 
        str += "</TD>" 
        str += "</TR>" 
        str += "</TABLE>" 
        str += "</DIV>" 
 
    oPopup.document.body.innerHTML = str;
   
 
    this.offset  = 0;
    var me  = this; 

    oPopup.document.body.onmouseover = function(){me.pause=true;}
    oPopup.document.body.onmouseout = function(){me.pause=false;}

    var fun = function(){ 
        var x  = me.left;
        var y  = 0;
        var width    = me.width;
        var height    = me.height;

            if(me.offset>me.height){
                height = me.height;
            } else {
                height = me.offset;
            }

        y  = me.bottom - me.offset;
        if(y<=me.top){
            me.timeout--;
            if(me.timeout==0){
                window.clearInterval(me.timer); 
                if(me.autoHide){
                    me.hide();
                }
            }
        } else {
            me.offset = me.offset + me.step;
        }
        me.Pop.show(x,y,width,height);   

    } 
 
    this.timer = window.setInterval(fun,this.speed)     
 
    
 
    var btClose = oPopup.document.getElementById("btSysClose"); 
 
    btClose.onclick = function(){ 
        me.close = true;
        me.hide(); 
    } 
 
    var btCommand = oPopup.document.getElementById("btCommand"); 
    btCommand.onclick = function(){ 
        me.oncommand(); 
    }   
  var ommand = oPopup.document.getElementById("ommand"); 
      ommand.onclick = function(){ 
       //this.close = true;
    me.hide(); 
 window.open(ommand.href);
    }  

/**//*
** 设置速度方法
**/
CLASS_MSN_MESSAGE.prototype.speed = function(s){
    var t = 20;
    try {
        t = praseInt(s);
    } catch(e){}
    this.speed = t;
}
/**//*
** 设置步长方法
**/
CLASS_MSN_MESSAGE.prototype.step = function(s){
    var t = 1;
    try {
        t = praseInt(s);
    } catch(e){}
    this.step = t;
}
 
CLASS_MSN_MESSAGE.prototype.rect = function(left,right,top,bottom){
    try {
        this.left        = left    !=null?left:this.right-this.width;
        this.right        = right    !=null?right:this.left +this.width;
        this.bottom        = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height;
        this.top        = top    !=null?top:this.bottom - this.height;
    } catch(e){}
}
var MSG1 = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有1封消息","懒人图库"); 
    MSG1.rect(null,null,null,screen.height-50);
    MSG1.speed    = 10;
    MSG1.step    = 5;
    //alert(MSG1.top);
    MSG1.show(); 

//同时两个有闪烁,只能用层代替了,不过层不跨框架
//var MSG2 = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有2封消息","好的啊"); 
//   MSG2.rect(100,null,null,screen.height);
//    MSG2.show(); 
//--> 
</SCRIPT>
 
    lz 我想这个应该是你要的效果,类似C/S的桌面右下角信息提示,希望能够帮到你~~~~~ --------------------编程问答-------------------- 其实就是弹出新页面而已,只是这个页面看着像消息框
但要完全模拟QQ的弹出效果是不可能的,因为web程序被限制在浏览器内,浏览器没这个权限。
除非你直接做个桌面应用,那么可以随便弹消息框 --------------------编程问答-------------------- 顶.............. --------------------编程问答-------------------- jxyxhz(小虎) 

效果不错,顶. --------------------编程问答-------------------- mark` --------------------编程问答-------------------- 这功能只有IE支持好象!
其他好象没有.Popwindow --------------------编程问答-------------------- mark。。。 --------------------编程问答-------------------- 回去研究研究,这个还是有用的。 --------------------编程问答-------------------- 收藏了  --------------------编程问答-------------------- 留名 收藏了 --------------------编程问答-------------------- 收藏下 --------------------编程问答-------------------- 用1 楼提供的地址, 用Jquery 实现! --------------------编程问答-------------------- 不在浏览器中 那肯定不是web程序啦 --------------------编程问答--------------------
引用 2 楼 jxyxhz 的回复:
HTML code
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Keywords" content="51windows.Net">
<META NAME="Author" CONTENT="haiwa">
<title>类似MSN提示的页面效果</……

在 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 文档类型下,你的代码是多么的不兼容 --------------------编程问答-------------------- 学习 真的不错! --------------------编程问答-------------------- 这是个好贴,收藏了, --------------------编程问答-------------------- --------------------编程问答-------------------- 围观各种代码 --------------------编程问答-------------------- MARK 同求 不是在浏览器中好不 同志们。。。发个系统中啊 像QQ那样的消息提醒啊
--------------------编程问答-------------------- --------------------编程问答-------------------- 这个不行哦。像校内人人网那样吧?那还是在浏览器以内,只不过用js做的一块一直贴着浏览器状态栏的浮动的div。至于实现方法,楼上的高手都说了 --------------------编程问答-------------------- 好多的源代码提供啊,
csdn这边右下角那个的布局可以考虑一下的。 --------------------编程问答-------------------- 楼主发错地方了,这里都是开发B/S的 --------------------编程问答--------------------
引用 2 楼  的回复:
HTML code

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Keywords" content="51windows.Net">
<META NAME="Author" CONTENT="haiwa">
<title>类似MSN提示的……

在火狐里面有兼容性问题, --------------------编程问答-------------------- 这是个好贴,收藏了,
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,