如题

解决方案 »

  1.   

    有一个作为参考.我写的,你自己修改下.JS压缩过的,不过还算看得清.原始的现在找不到
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
       <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
          <meta http-equiv="X-UA-Compatible" content="IE=7"/>
          <title>无标题文档</title>
          <style type="text/css">
             .instant1{ width:295px; height:33px;/* background:url(../images/welcome22.jpg) repeat-x; */padding-left:15px;}
             .instant1_1{ width:195px; height:33px; line-height:33px; color:#000; font-size:14px; float:left; ;}
             .instant1_2{ width:35px; height:25px; float:left;padding:8px 0 0 65px;cursor:pointer;}
             .instant{ width:310px;position:absolute; height:auto; border-left:1px solid #f38900;border-right:1px solid #f38900;border:1px solid #f38900;}
             .instant2{ width:270px; height:auto; float:left; padding:20px;/* background:url(../images/welcome23.jpg) repeat-x bottom; */font-size:12px; }
             .instant2 dl{ width:270px; height:28px;}
             .instant2 dt{ /*background:url(../images/welcome24.jpg) no-repeat left center; */float:left; height:28px; padding-left:10px; line-height:28px;}
             .instant2 dd{ float:left; padding:5px 0 0 10px; height:23px; }
          </style>
       </head>   <body>
          <input type="button" value="pop" onclick="f_s('div1')"/>
          <div style="">
             <p style="height:150px;">adfadf</p>
             <p style="height:150px;">adfadf</p>
             <p style="height:150px;">adfadf</p>
             <p style="height:150px;">adfadf</p>
             <p style="height:150px;">adfadf</p>
          </div>
          <!--
          <div id="div1" class="instant" style="display:none;">
             <div class="instant1">即时信息(5秒提示)<span style="cursor:hand;text-align:right;"><a onclick="closeW();">关闭</a></span></div>
             <div class="instant2">
                <dl>
                   <dt>你有3封未读邮件</dt>
                   <dd></dd>
                </dl>
                <dl>
                   <dt>最新公告通知(2009-10-30)</dt>
                   <dd></dd>
                </dl>
                <dl>
                   <dt>最新公告通知(2009-10-30)</dt>
                   <dd></dd>
                </dl>
                <dl>
                   <dt>最新公告通知(2009-10-30)</dt>
                   <dd></dd>
                </dl>
             </div>
          </div>
          <script type="text/javascript">
             (function() {
                var d = document.getElementById("div1");
                d.style.display="block";
                w = d.offsetWidth;
                h = d.offsetHeight;
                d.style.display="none";
             })();
          </script>
          -->
          <div id="div1" class="instant" style="display:none;">
             <div class="instant1">
                <div class="instant1_1">即时信息</div>
                <div class="instant1_2"><img src="../images/close.gif" onclick="closeW();"/></div>
             </div>
             <div class="instant2">
                <c:if test="${nc>0}">
                   <dl>
                      <dt><a href="">您有${nc}条公告</a></dt>
                      <dd><!--<img src="../images/welcome8.gif"/>--></dd>
                   </dl>
                </c:if>
                <c:if test="${mc>0}">
                   <dl>
                      <dt><a href="">您有${mc}条备忘录</a></dt>
                      <dd></dd>
                   </dl>
                </c:if>
                <c:if test="${notec>0}">
                   <dl>
                      <dt><a href="">您有${notec}条工作记录</a></dt>
                      <dd></dd>
                   </dl>
                </c:if>
                <c:if test="${ec>0}">
                   <dl>
                      <dt><a href="">您有${ec}条未读邮件</a></dt>
                      <dd></dd>
                   </dl>
                </c:if>
             </div>
          </div>
          <script type="text/javascript">
             (function(){
                var d=document.getElementById("div1");
                d.style.display="block";
                w=d.offsetWidth;
                h=d.offsetHeight;
                d.style.display="none";
                setTimeout("show()",2000);
             })();
             var flag=0,docE=document.documentElement||document.body,obj=document.getElementById("div1");function show(){obj.style.display="block";obj.style.height="1px";obj.style.filter="alpha(opacity="+70+")";obj.style.opacity=70/100;obj.style.MozOpacity=70/100;var A=docE.clientWidth,$=docE.clientHeight;obj.style.top=$-10;obj.style.left=A-w;var _=function(){var $=parseInt(obj.style.height);if($<h){obj.style.height=($+Math.ceil((h-$)/30))+"px";obj.style.top=parseInt(obj.style.top)-Math.ceil((h-$)/30)+"px"}else{clearInterval(bw1);setTimeout("closeW()",5000)}};bw1=setInterval(_,40);if(flag>0)clearInterval(bw2)}function closeW(){flag++;var $=function(){clearInterval(bw1);var $=parseInt(obj.style.height);if($>0){obj.style.top=parseInt(obj.style.top)+Math.ceil($)/30+"px";obj.style.height=($-Math.ceil($)/30)+"px"}else{clearInterval(bw2);obj.style.display="none"}};bw2=setInterval($,40)}function sc(){obj.style.top=(docE.scrollTop+docE.clientHeight-obj.offsetHeight-10)+"px";obj.style.left=(docE.scrollLeft+docE.clientWidth-obj.offsetWidth)+"px"}window.onload=sc;window.onscroll=sc;window.onresize=sc
          </script>
       </body>
    </html>
      

  2.   

    var flag=0;
       var docE=document.documentElement||document.body;
       var obj=document.getElementById("div1");
       function show(){
          obj.style.display="block";
          obj.style.height="1px";
          obj.style.filter="alpha(opacity="+70+")";
          obj.style.opacity=70/100;
          obj.style.MozOpacity=70/100;
          var sw=docE.clientWidth;
          var sh=docE.clientHeight;
          obj.style.top=sh-10;
          obj.style.left=sw-w;      var changeW=function(){
             var obj_h=parseInt(obj.style.height);
             if(obj_h<h){
                obj.style.height=(obj_h+Math.ceil((h-obj_h)/30))+"px";
                obj.style.top=parseInt(obj.style.top)-Math.ceil((h-obj_h)/30)+"px";
             } else{
                clearInterval(bw1);
                setTimeout("closeW()",5000);
             }
          }
          bw1=setInterval(changeW,40);
          if(flag>0){
             clearInterval(bw2);
          }
       }
       function closeW(){
          flag++;
          var closeDiv=function(){
             clearInterval(bw1);
             var obj_h=parseInt(obj.style.height);
             if(obj_h>0){
                obj.style.top=parseInt(obj.style.top)+Math.ceil(obj_h)/30+"px";
                obj.style.height=(obj_h-Math.ceil(obj_h)/30)+"px";
             } else{
                clearInterval(bw2);
                obj.style.display="none";
             }
          }
          bw2=setInterval(closeDiv,40);
       }
       function sc(){
          obj.style.top=(docE.scrollTop+docE.clientHeight-obj.offsetHeight-10)+"px";
          obj.style.left=(docE.scrollLeft+docE.clientWidth-obj.offsetWidth)+"px";
       }   window.onload=sc;
       window.onscroll=sc;
       window.onresize=sc;