这里有段抄来的代码,希望对你有用.function f_frameStyleResize(targObj){    var targWin = targObj.parent.document.all[targObj.name];
    if(targWin != null) {
        var HeightValue = targObj.document.body.scrollHeight
        if(HeightValue < 400){HeightValue = 400} 
        targWin.style.pixelHeight = HeightValue;
    }}function f_iframeResize(){    bLoadComplete = true; f_frameStyleResize(self);
} var bLoadComplete = false;
 window.onload = f_iframeResize; 这段代码的意思是根据iframe的高度,自动调整父窗口中iframe的高度,让iframe全显示出来.

解决方案 »

  1.   

    不是窗口加载的时候,是加载完毕以后的事件触发。
    <html>   
    <body onresize="alert('bodyResize:' + this.scrollHeight)">   
        <textarea style="overflow-y:visible" onresize ='alert("textareaResize="+this.scrollHeight)'>
        TEST
       </textarea>
    <div   contentEditable>   
    <img width="150px"   height="200px"   onresizeend="alert('imgResize:' + this.scrollHeight);">   
    </div>
    </body>   
    </html> 问题无法触发body的onresize事件
      

  2.   

    <!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>shawl.qiu template</title>
    <style type="text/css">
    /* <![CDATA[ *//* ]]> */
    </style>
    <script type="text/javascript">
    /*<![CDATA[*/
     if (navigator.appName=="Microsoft Internet Explorer") 
     {
      //最大化窗口
      self.moveTo(-5,-5)
      self.resizeTo(screen.availWidth +8,screen.availHeight+8)
      //这个脚本定义的宽度其实比原窗口还要大那么一点.
     }
    /*]]*/
    </script>
    </head>
    <body>
    <script type="text/javascript">
    /*<![CDATA[*/
    onresize =
     function()
     {
      defaultStatus = fGetViewPortSize(); 
     }
    function fGetViewPortSize() 
    {// shawl.qiu code, return Array
     var myWidth = 0, myHeight = 0;
     if(typeof(window.innerWidth ) == 'number' ) 
     {//Non-IE
      myWidth = window.innerWidth;
      myHeight = window.innerHeight;
     } 
     else if 
     (
      document.documentElement && 
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) 
      ) 
     {//IE 6
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
     } 
     else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
     { //IE 4
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
     }
     return [myWidth, myHeight];
    } // end function fGetViewPortSize
    /*]]*/
    </script>
    </body>
    </html>
      

  3.   

    onload也要:
    <body onresize="alert('bodyResize:' + this.scrollHeight)">
    --->>>
    <body onresize="alert('bodyResize:' + this.scrollHeight)" onload="alert('bodyResize:' + this.scrollHeight)">
      

  4.   

    谢谢各位的答复。可能是我没有说清楚。
    <html>   
    <body onresize="alert('bodyResize:' + this.scrollHeight)">   
        <textarea style="overflow-y:visible" onresize ='alert("textareaResize="+this.scrollHeight)'>
        TEST
       </textarea>
    <div   contentEditable>   
    <img width="150px"   height="200px"   onresizeend="alert('imgResize:' + this.scrollHeight);">   
    </div>
    </body>   
    </html>
    页面里面有个textarea,可以自动增行,img 可以拖拉大小。我的问题是textarea增行、img 拖动的时候没有触发body的onresize事件。