当前位置:asp编程网>技术教程>Javascript教程>  正文

javascript慢慢收缩和展开效果

2009-07-08 14:05:22   来源:网络    作者:佚名   浏览量:2104   收藏

[code]
<!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" />
<title>无标题 1</title>
<script>
var flag=0;
function f_s(id){
       var obj=document.getElementById(id);
       obj.style.display="block";
       obj.style.height="1px";
         
       var changeW=function(){     
              var obj_h=parseInt(obj.style.height);
              if(obj_h<=335){
                     obj.style.height=(obj_h+Math.ceil((335-obj_h)/10))+"px";
              }
              else{
              clearInterval(bw1);
              }
       }      
       bw1= setInterval(changeW,1);
    if(flag>0){
      clearInterval(bw2);
    }
}
function closeW(id){
  flag++;
       var obj=document.getElementById(id);
       var closeDiv=function(){
      
        clearInterval(bw1);
              var obj_h=parseInt(obj.style.height);
              if(obj_h>1){
                     obj.style.height=(obj_h-Math.ceil(obj_h)/10)+"px";
     
              }
              else{
              clearInterval(bw2);
              obj.style.display="none";
              }
       }        
      bw2= setInterval(closeDiv,1);
   //alert(flag)
}
function showDiv(){
 var ele = document.getElementById("div1");
 clearInterval(bw1);
 clearInterval(bw2);
 ele.style.display = "block";
 ele.style.height = 335 + "px";
 
 
}
</script>
</head>
<body>
<div onmouseover="f_s('div1')"  onmouseout="closeW('div1')" style=" position:absolute;background:black; left: 579px; top: 34px; width: 149px; height: 35px;">
</div>
<div id="div1" style="position:absolute;background:aqua;left:451px;overflow:hidden;top:70px;width:349px;display:none" onmouseover="showDiv()" onmouseout="closeW('div1')"></div>
</body>
</html>
[/code]



关于我们-广告合作-联系我们-积分规则-网站地图

Copyright(C)2013-2017版权所属asp编程网