Asp.Net 实现仿MSN提示窗口

来源:互联网 发布:淘宝索尼手机 编辑:程序博客网 时间:2024/06/09 20:56


这个是javascript部分的代码

<script language="javascript">
<!--
window.onload = getMsg;
window.onresize = resizediv;
window.onerror = function(){}
//短信提示使用(FHB添加)
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>300) 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: 700px; visibility: hidden; border-left: #a6b4cf 1px solid;
        width: 249px; border-bottom: #455690 1px solid; position: absolute; top: 500px;
        height: 151px; background-color: #cee1c4">
        <table width="100%" height="151" border="0" cellpadding="0" cellspacing="1" bgcolor="green"
            style="border-top: #ffffff 1px solid; border-left: #ffffff 1px solid">
            <tbody>
                <tr bgcolor="#6699cc">
                    <td width="1" height="24" bgcolor="#6699cc" style="font-size: 12px; color: #0f2c8c">
                    </td>
                    <td width="206" valign="middle" bgcolor="green" style="padding-left: 4px; font-weight: normal;
                        font-size: 12px; color: #ffffff; padding-top: 2px">
<%--                        <a href="Customer_View/Custmoer_cus_away.aspx">
                            <asp:Label ID="lblBirthday" runat="server"></asp:Label></a> <a href="Customer_View/Custmoer_cus_away.aspx">
                                有<asp:Label ID="lblBargain" runat="server"></asp:Label>个合同今天到收款日期</a>--%>
               友情提示
                    </td>
                    <td width="39" align="right" valign="middle" bgcolor="green" style="padding-right: 2px;
                        padding-left: 3px; padding-top: 2px; font-size: 12px">
                        <span title="关闭" style="font-size: 12px; cursor: hand; color: white; margin-right: 2px"
                            onclick="closediv()">关闭</span>
                    </td>
                </tr>
                <tr>
                    <td height="90" colspan="3" align="center" bgcolor="#afe195" style="padding-right: 5px;
                        padding-left: 5px; padding-bottom: 3px; padding-top: 3px; font-size: 12px;">
                        &nbsp;&nbsp;

                            <a href="BirthdayInfo.aspx"><asp:Label ID="lblBirthday" runat="server"></asp:Label></a>
                                <a href="Bargain.aspx"> <asp:Label ID="lblBargain" runat="server"></asp:Label></a>
                
                    </td>
                </tr>
            </tbody>
        </table>
    </div>

值可以从后台获得,然后赋入label标签就可以,自己可以做一些调整,比较好改

原创粉丝点击