<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<title></title><SCRIPT LANGUAGE=javascript>
<!--
function test(){
var w=document.all.text1.value;
var h=document.all.text2.value;

document.all.frm.style.width=w;
document.all.frm.style.height=h;
}
//-->
</SCRIPT>
</head>
<body onload="test()">
<iframe name=frm src="about:blank"></iframe>
<BR>
width:<INPUT type="text" id=text1 name=text1 value="200">
height:<INPUT type="text" id=text2 name=text2 value="100">
<INPUT type="button" value="change" id=button1 name=button1 onclick="test()">
</body>
</html>

解决方案 »

  1.   

    function window.onload()
    {
        if(top.location != self.location)
        {
          var a = window.parent.document.getElementsByTagName('iframe');
            for (var i=0; i<a.length; i++)
            {
                if (a[i].name == self.name) 
                {
                    a[i].height = document.body.scrollHeight; return;
    //这只是改变高的代码,你也可以将宽的代码加进去document.body.scrollWidth
                }
            }
        }  
    }
      

  2.   

    <iframe id=theFrame src="about:content_here"></iframe>
    <button onclick="with(document.all.theFrame){height=offsetHeight+10;width=offsetWidth+10;}">+</button>
      

  3.   

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body bgcolor="#3300CC">
    width:<input type=text name=w value=90>
    height:<input type=text name=h value=90><IFRAME frameBorder=1 name=heads src="about:blank" style="HEIGHT: expression(h.value); LEFT: 220px; POSITION: absolute; TOP: 200px; WIDTH: expression(w.value)">
    </IFRAME>
    </body>
    </html>
      

  4.   

    这样吧,我贴我的代码:你们看为什么不能运行?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD><BODY onload="myonload()">
    <script>
    function myonload()
    {
            testframe.width='200px';
    }
    </script>
    <iframe name="testframe" width="100px" height="100px"></BODY>
    </HTML>
      

  5.   

    testframe.width='200px';
    -->
    document.all.testframe.width='200px';
      

  6.   

    用setInterval每隔一定的时间改变一次iframe的高度。
      

  7.   

    <script>
    function myonload()
    {
            testframe.style.width=200;
    }
    </script>
    <iframe name="testframe"  height="100px">
      

  8.   

    谢谢大家了!分我一定给,
    还有回答了问题的朋友,请去
    http://expert.csdn.net/Expert/topic/1447/1447682.xml?temp=8.916873E-02
    贴一下还有我问了半天,总算找到了问题的症结所在,如flyycyu(fly)所写,
    document.all.testframe.width='200px';
    可以正常运行而像 fason(不独) 写的,也就是我的写法,不报错,但运行也不正确