怎样让页面随iframe大小变化~! ???   我的一个iframe里面有个页面  iframe大小变化时 页面大小也随着变化~!如  qq论坛::http://bbs.love.qq.com/cgi-bin/bbs/user/user_enter_bbs?g=f&url=/lanmu/101.shtml

解决方案 »

  1.   

    document.getElementById("frame_main").style.height=frame_main.document.body.scrollHeight+1+"px";
    <iframe src=<%=opensrc %> id="frame_main" name="frame_main" onload="change_size()" style="border-style:solid;border-width:0;padding:0;" marginwidth="1" marginheight="1" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
      

  2.   


    <script language="javascript" type="text/javascript">
     //获取浏览器窗口宽
    function getViewportInfoWidth()
    {
        var w = (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;    return w;
    }
    //获取浏览器窗口高
    function getViewportInfoHeight()
    {    var h = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
        return h;
    }
     
    document.getElementById("iframe1").width=getViewportInfoWidth();
    document.getElementById("iframe1").height=getViewportInfoHeight(); 
    </script>这是随页面大小变化的!
      

  3.   

    <!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>iframe</title>
    </head>
    <body>
    <script type="text/javascript">
    function SetCwinHeight(){
      var bobo=document.getElementById("bobo"); //iframe id
      if (document.getElementById){
       if (bobo && !window.opera){
        if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight){
         bobo.height = bobo.contentDocument.body.offsetHeight;
        }else if(bobo.Document && bobo.Document.body.scrollHeight){
         bobo.height = bobo.Document.body.scrollHeight;
        }
       }
      }
    }
    </script>
    <iframe width="100%" id="bobo" onload="Javascript:SetCwinHeight()" height="1" frameborder="0" src="IFrame_myPage.aspx"></iframe>
    其实很简单</body>
    </html>
      

  4.   

    上面的搞错了,是随BODY的!
    下面的是:<iframe id="sqiframe" name="sqiframe" src="<%=iframeurl%>" frameborder="0" width="100%" onload="AdjustHeight();"></iframe>
    <script language="javascript" type="text/javascript">
    function AdjustHeight()
    {
        if(sqiframe.document.body.scrollHeight+40 < 485)
        {
            document.getElementById("sqiframe").height = 485;//原560
        }
        else
        {
            document.getElementById("sqiframe").height=sqiframe.document.body.scrollHeight+40
        }
    }
    </script>
      

  5.   

    各位大哥 我要的是qq论坛的效果  http://bbs.love.qq.com/cgi-bin/bbs/user/user_enter_bbs?g=f&url=/lanmu/101.shtml
      

  6.   

    晕!你标题标的不明,这个很简单!
    这个是利用frameset ,如下代码给你提示:<frameset cols="167,6,100%" framespacing="0" frameborder="NO" border="0" name="main" id="main">
    <frame src="LeftMenu.aspx?un=<%=username%>" name="leftmiddle"   TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" FRAMEBORDER="0" border="0" bordercolor="#8AB8E9" scrolling="auto" >
    <frame src="Frameset/framemiddle.htm" name="framemiddle" id="framemiddle" scrolling="NO"  TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" FRAMEBORDER="0" border="0" bordercolor="#8AB8E9" >

    <frame name="MainData" id="MainData" src="RigtMain.aspx?un=<%=username%>" TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" FRAMEBORDER="0" border="0" bordercolor="#8AB8E9"  scrolling="yes"> </frameset> <frame src="Frameset/bottom.htm" name="bottom" scrolling="NO" noresize>
    </frameset>