当前位置: 代码迷 >> ASP.NET >> 当有数据更新浏览器右下角弹出消息框提示 如何用asp.net做
  详细解决方案

当有数据更新浏览器右下角弹出消息框提示 如何用asp.net做

热度:7468   发布时间:2013-02-25 00:00:00.0
当有数据更新浏览器右下角弹出消息框提示 怎么用asp.net做
当有数据更新浏览器右下角弹出消息框提示 怎么用asp.net弄 ? 如果用js或popupwin第三方控件有具体怎么做?

------解决方案--------------------------------------------------------
探讨

用JS或者Jquery实现
http://www.codefans.net/soft/4545.shtml
http://www.jb51.net/article/25951.htm

------解决方案--------------------------------------------------------
JScript code
window.onresize = resizeDiv; //根据窗体高度和宽度,改变短消息提示框的高度和宽度 window.onerror = function(){} //出现错误时,不做任何处理 var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;//关于位置的相关变量 function $int(num){try{return parseInt(num);}catch(ex){return 0;}}function viewMsg() {     try{         var divElement = $(divName);        divTop = $int(divElement.style.top) //div的x坐标         divLeft = $int(divElement.style.left) //div的y坐标         divHeight = $int(divElement.offsetHeight)//div的高度         divWidth = $int(divElement.offsetWidth) //div的宽度         docWidth = document.documentElement.clientWidth; //窗体宽度         docHeight = document.documentElement.clientHeight; //窗体高度         divElement.style.top = docHeight + 10;//设置div的Y坐标         divElement.style.left = docWidth - divWidth//设置div的X坐标         divElement.style.visibility="visible" //设置div显示         objTimer = window.setInterval("moveDiv()",10) //设置定时器     }catch(e){alert("viewMsg"+e.description);} } function resizeDiv(){     i+=1     if (i>500) closeDiv()     try{         var divElement = $(divName);        divHeight = $int(divElement.offsetHeight) //设置div高度         divWidth = $int(divElement.offsetWidth) //设置div宽度         docWidth = document.documentElement.clientWidth; //获取窗体宽度         docHeight = document.documentElement.clientHeight; //设置窗体高度         divElement.style.top = docHeight - divHeight;// + $int(document.body.scrollTop)//设置div的y坐标         divElement.style.left = docWidth - divWidth;// + $int(document.body.scrollLeft)//设置div的x坐标     }catch(e){alert("resizeDiv"+e.description);} } function moveDiv(){     try{         var divElement = $(divName);        if ($int(divElement.style.top) <= (docHeight - divHeight)){             window.clearInterval(objTimer)             objTimer = window.setInterval("resizeDiv()",1) //调整div的位置和大小         }         divTop = $int(divElement.style.top)//获取y坐标         divElement.style.top = divTop - 1//调整div的Y坐标     }     catch(e){alert("moveDiv"+e.description);} } function closeDiv(){     var divElement = $(divName);    divElement.style.visibility='hidden';//将短信息提示层隐藏     if(objTimer) window.clearInterval(objTimer); //清除定时器 }
------解决方案--------------------------------------------------------
前台:
C# code
 <input type="hidden" onclick="viewMsg()" runat="server" id="hidMsg" value="0" />    <div id="divMsg" 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; color: #0f2c8c" width="30" height="24">                    </td>                    <td style="font-weight: normal; font-size: 12px; color: #1f336b; padding-top: 4px;                        padding-left: 4px" valign="center" width="100%">                        Mac审批提示:</td>                    <td style="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></td>                </tr>                <tr>                    <td style="padding-right: 1px; 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"><%= msgCount.ToString() %></font>条Mac申请待您审批!<br>                            <br>                            <div align="center" style="word-break: break-all">                                <a href='ComMacApply.aspx?Com_ID=<%= Com_ID %>' target="_blank"><font color="#FF0000">点击查看申请</font></a></div>                        </div>                    </td>                </tr>            </tbody>        </table>    </div><script type="text/javascript" language="javascript">        var divName="divMsg";         window.onload=function(){            var hid = $('<%= hidMsg.ClientID %>');            if(hid.value!="0")                hid.fireEvent("onclick");//主要就是这个了,以后如果有数据更新,就触发一次hidMsg的onclick事件        }           </script>
  相关解决方案