onload="this.style.height=iframe.document.body.scrollHeight"
以上这种方法在iframe外点击一个链接到iframe里可以自适应高度,可是在iframe里的页面点击一个链接仍然到这个iframe里就不能自适应高度了,有什么解决的方法没?
请高手赐教!

解决方案 »

  1.   

    function AutoHeight(obj)
    {    
        var subWeb = document.frames ? document.frames[obj.name].document : obj.contentDocument;    if(obj != null && subWeb != null)
        { 
            obj.height = subWeb.body.scrollHeight;
        }
    }function AutoWidth(obj)
    {    
        var subWeb = document.frames ? document.frames[obj.name].document : obj.contentDocument;
        
        if(obj != null && subWeb != null)
        { 
            obj.width = subWeb.body.scrollWidth;
        }
    }
    <iframe src="Content.aspx" id="cFrame" name="cFrame" scrolling="no" frameborder="0"
                onload="Javascript:AutoWidth(this);AutoHeight(this);"></iframe>
      

  2.   

    或在被iframe里的窗体

    function AutoSize()
    {
        if (window != top)
        {
            window.resizeTo(window.document.body.scrollWidth, window.document.body.scrollHeight);
        }
    }<body onload=" AutoSize()">
    </body>
      

  3.   

    你为什么不设置IFRRAM1.style.height=document.body.scrollheight呢!这里的THIS指的是什么啊
      

  4.   

    "你为什么不设置IFRRAM1.style.height=document.body.scrollheight呢!这里的THIS指的是什么啊 
    !"
    那种方法有时不好用。