LZ没说原因
试了一下,张开的过程停不下来
修改如下:<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/> 
<title>无标题文档 </title> 
<script language="javascript" type="text/javascript"> 
window.onload = zhankai; 
var maxheight = 100;
function zhankai(){ 
var w = document.getElementById("div1").offsetWidth; 
var h = document.getElementById("div1").offsetHeight;  document.getElementById("div1").style.width = (w+1) + "px"; 
document.getElementById("div1").style.height = (h+1) + "px";
if(h < maxheight){
setTimeout("zhankai()",10); 


</script> 
</head> <body> <div id="div1" style="width:50px;height:20px;border:#000000 1px solid;">朋友们</div> 
<div id="show"> </div> </body> 
</html> 

解决方案 »

  1.   


    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>无标题文档 </title> 
    <script language="javascript" type="text/javascript"> 
    function zhankai() { 
    var maxheight=100; 
    var obj=document.getElementById("div1")
    var w=obj.offsetWidth; 
    var h=obj.offsetHeight; 
    obj.style.width=(w+1)+"px"; 
    obj.style.height=(h+1)+"px"; 
    if(h<maxheight)
    setTimeout(zhankai,1); 
    }
    function zhankai2() { 
    var maxheight=100; 
    var maxwidth=100; 
    var obj=document.getElementById("div2")
    var w=obj.offsetWidth; 
    var h=obj.offsetHeight; 
    if(h<maxheight)obj.style.height=(h+2)+"px";
    else if(w<maxwidth)obj.style.width=(w+2)+"px";
    else clearTimeout(timer)
    timer=setTimeout(zhankai2,1); 
    }function zhankai3() { 
    var maxheight=100; 
    var maxwidth=100; 
    var obj=document.getElementById("div3")
    var w=obj.offsetWidth; 
    var h=obj.offsetHeight; 
    if(w<maxwidth)obj.style.width=(w+3)+"px";//不够宽则加宽
    else if(h<maxheight)obj.style.height=(h+3)+"px";//不够高则加高
    else clearTimeout(timer)//宽高都够了
    timer=setTimeout(zhankai3,1); 
    }
    </script> 
    <style>
    div {width:80px; height:20px; border:#000000 1px solid;font-size:12px;margin:10px;}
    </style>
    </head> <body> <div id="div1" onclick="zhankai()">朋友们-请点击 </div> 
    <div id="div2" onclick="zhankai2()">朋友们-请点击 </div> 
    <div id="div3" onclick="zhankai3()">朋友们-请点击 </div> 
    </body> 
    </html>