本人在做一个计算器,用了iframe框架,在iframe里那个html中 希望有一个效果是本来有一个隐藏的div 点击计算后显示出来,此时iframe的高度随内容变化而增高,在网上找了很多方法 google浏览器都不兼容,也没找到合适的解决办法 
代码如下:希望达到的效果是 计算结果本来不显示 点击计算button 后显示 高度也随之改变1.
test.html
<html>
  <head>
    <meta http-equiv="content-type" content="text/html;charset=gb2312;" />
  </head>
  <body>
  <div id="a" style="border:1px dashed #999999;">
  <div id="b">
  计算器<br/>
  </div>
  
  <iframe src="content.html" onload="addEvt(this)"  frameborder="0" style="border:solid 1px black;" marginheight="0" marginwidth="0"></iframe>
   </div>
<script type="text/javascript">
function addEvt(ifr){
  var doc=ifr.contentWindow.document;
  doc.onclick=function(){
    //ifr.style.height=(document.all?doc.body.scrollHeight:doc.body.offsetHeight)+'px';
   ifr.style.height=doc.body.firstChild.offsetHeight;//有根节点可以使用根节点,兼容性比较好,opera,safari,google的浏览器都可以兼容,如果使用body.offsetHeight只在ff下有效果
  }
  ifr.style.height=doc.body.scrollHeight;
}
</script></body>
</html>
2.content.html:
<html>
  <head>
    <meta http-equiv="content-type" content="text/html;charset=gb2312;" />
  <body style="height:auto">
<div id="dvMain">
  <form name="loandata">  
            <table>  
                <tr><td colspan="3"><b>输入贷款信息:</b></td></tr>  
                <tr>  
                      <td>1)</td>  
                      <td>贷款总额:</td>  
                      <td><input type="text" name="principal" size="12" onChange="calculate();"></input></td>  
               </tr>  
                <tr>  
                       <td>2)</td>  
                       <td>年利率(%):</td>  
                       <td><input type="text" name="interest" size="12" onChange="calculate();"></input></td>  
                </tr>  
                <tr>  
                       <td>3)</td>  
                       <td>还款期限(年):</td>  
                       <td><input type="text" name="years" size="12" onChange="calculate();"></input></td>  
                  </tr>  
                  <tr><td colspan="3"><input type="button" value="计算" onClick="calculate();"></td></tr>  
  
                  <tr><td colspan="3"><b>输入还款信息:</b></td></tr>  
                  <tr>  
                       <td>4)</td>  
                       <td>每月还款金额:</td>  
                       <td><input type="text" name="payment" size="12" ></input></td>  
                 </tr>  
                 <tr>  
                       <td>5)</td>  
                       <td>还款总金额:</td>  
                       <td><input type="text" name="total" size="12" ></input></td>  
                </tr>  
                <tr>  
                    <td>6)</td>  
                    <td>还款总利息:</td>  
                    <td><input type="text" name="totalinterest" size="12" ></input></td>  
                </tr>  
  </table>  
</div>
</body>
<script type="text/javascript">  
 function calculate(){  
             //贷款总额  
         //把年利率从百分比转换成十进制,并转换成月利率。  
         //还款月数  
               var principal = document.loandata.principal.value;  
               var interest = document.loandata.interest.value/100/12;  
               var payments = document.loandata.years.value*12;  
     
            //计算月支付额,使用了相关的数学函数。  
               var x=Math.pow(1+interest,payments);  
               var monthly=(principal*x*interest)/(x-1)  
  
            //检查结果是否是无穷大的数。如果不是,就显示出结果。  
                if(!isNaN(monthly)&&  
                    (monthly!=Number.POSITIVE_INFINITY)&&  
                    (monthly!=Number.NEGATIVE_INFINITY)){  
                            document.loandata.payment.value=round(monthly);  
                            document.loandata.total.value=round(monthly*payments);  
                            document.loandata.totalinterest.value=round((monthly*payments)-principal);  
                   }  
               //否则,用户输入的数据是无效的,因此什么都不显示。  
                  else{  
                              document.loandata.payment.value="";  
                              document.loandata.total.value="";  
                              document.loandata.totalinterest.value="";  
    }  
  }  
  
 //把数字舍入成两位小数的形式。  
    function round(x){  
             return Math.round(x*100)/100;  
     }  
   
</script>  
</html>求大神解答!!!