我实现在右下角弹出消息框的效果,出现的时候是从下往上缓慢出现的,可是关闭的时候一点关闭很快关闭了,大家帮帮忙,如何实现逐渐从上往下退出关闭的效果。
现在是这样写的:
function closeDiv()
{
  document.getElementById('eMeng').style.visibility='hidden';
  if(objTimer) window.clearInterval(objTimer)
}

解决方案 »

  1.   

    function changeH(str) {
     var MsgPop=document.getElementById("winpop");
     var popH=parseInt(MsgPop.style.height);
     if(str=="up"){
      if (popH<=180){
      MsgPop.style.height=(popH+4).toString()+"px";
      }
      else{
      clearInterval(show);
      }
     }
     if(str=="down"){ 
      if (popH>=4){  
      MsgPop.style.height=(popH-4).toString()+"px";
      }
      else{ 
      clearInterval(hide);   
      MsgPop.style.display="none";  //隐藏DIV
      }
     }
    }用这个方法

    function tips_pop(){
    show=setInterval("changeH('up')",2);
       }
      else { 
       hide=setInterval("changeH('down')",2);}
    调用 
    tips_pop()就行了
      

  2.   

    function changeSmall()
    {
       div 宽度-1
       判断下如果==0 就
    document.getElementById('eMeng').style.visibility='hidden';
    clearInterval();
    }setInterval(changeSmall,1000);
      

  3.   

    你div弹出的效果是如何实现的呢?套用一下为!
      

  4.   

    <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>
    </body>
    </html>