<script>
function a()
{
.
.
.
  for(var i=0;i<xx,i++)
  {
   //cell3是动态生成的<td></td>(一列)
   //动态生成iframe,
      var cea = document.createElement("iframe");
      cea.id = 'cwin'+i;
      cea.scrolling = 'no';
      cea.src = link;
      cea.width = '100%';
      cell3.appendChild(cea);
      var win='cwin'+i;
      //alert(win);         当我把这句话加入时,运行正确,如果注释掉这句话,就报错:没有对象,行数:80(蓝色那行)。
      SetCwinHeight(win);
   }
}//iframe自适应高度
function SetCwinHeight(win)
{
    var cwin=document.getElementById(win);
    cwin.height=cwin.Document.body.scrollHeight;   --80行
}</script><body onload="a()">

解决方案 »

  1.   

    试了 不管用。最后是:cwin.height=parent.document.body.scrollHeight; 管用了。不知道为什么!
      

  2.   

    parent.document.body.scrollHeight这个指的是父窗口的高
      

  3.   


    <script> 
    function   a() 




        for(var   i=0;i <xx,i++) 
        { 
          //cell3是动态生成的 <td> </td> (一列) 
          //动态生成iframe, 
                var   cea   =   document.createElement("iframe"); 
                cea.id   =   'cwin'+i; 
                cea.scrolling   =   'no'; 
                cea.src   =   link; 
                cea.width   =   '100%'; 
                cell3.appendChild(cea); 
                var   win='cwin'+i; 
                //alert(win);                   当我把这句话加入时,运行正确,如果注释掉这句话,就报错:没有对象,行数:80(蓝色那行)。 
                setTimeout("SetCwinHeight("+win+");",1000);//延迟一下试试,可能是动态加载元素还没结束。 
          } 
    } //iframe自适应高度 
    function   SetCwinHeight(win) 

            var   cwin=document.getElementById(win); 
            cwin.height=cwin.Document.body.scrollHeight;       --80行 
    } </script> <body   onload="a()"> 
      

  4.   

    如果确认是异步执行的问题,就可以通过时间延迟来解决啊。
    改下试试:<script> 
    function   a() 




        for(var   i=0;i <xx,i++) 
        { 
          //cell3是动态生成的 <td> </td> (一列) 
          //动态生成iframe, 
                var   cea   =   document.createElement("iframe"); 
                cea.id   =   'cwin'+i; 
                cea.scrolling   =   'no'; 
                cea.src   =   link; 
                cea.width   =   '100%'; 
                cell3.appendChild(cea); 
                var   win='cwin'+i; 
                //alert(win);                   当我把这句话加入时,运行正确,如果注释掉这句话,就报错:没有对象,行数:80(蓝色那行)。 
                SetCwinHeight(win); 
          } 
    } //iframe自适应高度 
    function   SetCwinHeight(win) 

            var   cwin=document.getElementById(win); 
            if(cwin.document.body)cwin.height=cwin.document.body.scrollHeight;       --80行 
             else setTimeout("setCwinHeight("+win+");",1000);
    } </script> <body   onload="a()"> 
      

  5.   

    以下部分代码完整提供下<script> 
    function   a() 




        for(var   i=0;i <xx,i++) 
        { 
          //cell3是动态生成的 <td> </td> (一列) 
          //动态生成iframe, 
                var   cea   =   document.createElement("iframe"); 
                cea.id   =   'cwin'+i; 
                cea.scrolling   =   'no'; 
                cea.src   =   link; 
                cea.width   =   '100%'; 
                cell3.appendChild(cea); 
                var   win='cwin'+i; 
                //alert(win);                   当我把这句话加入时,运行正确,如果注释掉这句话,就报错:没有对象,行数:80(蓝色那行)。 
                setTimeout("SetCwinHeight("+win+");",1000);//延迟一下试试,可能是动态加载元素还没结束。 
          } 
      

  6.   

    不知道你的意思。你那个80行报的错应该是指:缺乏cwin.document.body这个对象。
    还有一种可能性:你原帖中cwin.document写成了cwin.Document。是不是缺乏Document这个对象。
    你自己再查查吧。
      

  7.   

    同意楼上,没有HTML代码,对牛弹琴
      

  8.   

    <%@ Page language="c#" Codebehind="menugoogle1.aspx.cs" AutoEventWireup="false" Inherits="t.menugoogle1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>menugoogle1</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <script type=text/javascript>

    var xmlHttp;

    function pageload()
    {
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET","content1.xml",true);
    xmlHttp.send(null);
    }
        
    function createXMLHttpRequest()
    {
    if(window.ActiveXObject)
    {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest)
    {
    xmlHttp = new XMLHttpRequest();
    }
    }

    function handleStateChange()
    {
    if(xmlHttp.readyState == 4)
    {
    if(xmlHttp.status == 200)
    {
    ListMenu1(); //第一階Menuを表示する。
    }
    }
    }
    function ListMenu1()
    {
    var mainmenu = xmlHttp.responseXML;
    var menunode = mainmenu.getElementsByTagName("content");
    CreateRow(menunode); //functionを引用する、機能は第一階Menuを作る
    }
        
        function CreateRow(menu)
        {
    document.getElementById("newTable").innerHTML=document.getElementById("newTable").innerHTML+"<table id=tb11 align=center  border=0 width=100% cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#000099\"></table>";

    var tdData1 = document.getElementById("tb11");



    len=menu.length;
    var Title="title";
    var Link="link";
    var L_img="Limg";
    var C_img="Cimg";
    var R_img="Rimg";

    for(var i=0;i<len;i++)
    {

    content=menu[i];

    var title=getElement(content,Title);
    var link=getElement(content,Link);
    var L=getElement(content,L_img);
    var C=getElement(content,C_img);
    var R=getElement(content,R_img);
    //alert(R);
    //alert(a);
    var newRow=tdData1.insertRow(2*i);//新行を追加する  
    newRow.height=35;
    //newRow.bgcolor="#99ccff;";
    newRow.border=0;
    var cell0=newRow.insertCell(0);//列を追加する
    cell0.align = "right";
    cell0.id=2*i;
    cell0.style.cssText="width:2%;FONT-WEIGHT: bold;color:white;";
    cell0.background=L;
    //cell0.border=0;

    var cell1=newRow.insertCell(1);
    cell1.align="center";
    //cell1.valign="top";
    //cell1.width="96%";
    //cell1.id=
    cell1.innerText=title;
    cell1.style.cssText="font-size:18px;FONT-WEIGHT: bold;";
    cell1.background=C;
    cell1.border=0;

    var cell2=newRow.insertCell(2);
    //
    cell2.align="left";

    cell2.style.cssText="width:3%;FONT-WEIGHT: bold;";
    cell2.background=R;
    cell2.border=0;

    var newRow=tdData1.insertRow(2*i+1);//新行を追加する  
    newRow.height=300;
    //newRow.border=0;
    var cell3=newRow.insertCell(0);
    cell3.align="center";
    cell3.valign="top";
    cell3.id=2*i+1;

    cell3.colSpan=3;
    //alert(link);
    //cell3.innerHTML='<iframe border=0 id=cwin'+i+' width=100% scrolling=no align=top src='+link+'></iframe>';
    var cea = document.createElement("iframe");
    cea.id = 'cwin'+i;
    cea.scrolling = 'no';
    cea.src = link;
    cea.width = '100%';
    cell3.appendChild(cea);

    var win='cwin'+i;
    alert(win);
    SetCwinHeight(win);
    }
    f=1;
        }
        
    function getElement(menu,ele)
    {
    if(menu.getElementsByTagName(ele)[0])
    {
    if(menu.getElementsByTagName(ele)[0].firstChild)
    return menu.getElementsByTagName(ele)[0].firstChild.nodeValue;
    else
    return "";
    }
    else
    {
    return "";
    }
    }


    function SetCwinHeight(len)
    {
    //var cwin=document.getElementById("cwin");




    //alert(win);
    var cwin=document.getElementById(win);
    cwin.height=cwin.Document.body.scrollHeight;

    /////cwin.width=cwin.Document.body.scrollWidth;

    /*for(var i=0;i<len;i++)
    {
    //alert(f);
    var win='cwin'+i;
    //alert(win);
    var cwin1=document.getElementById(win);
    cwin1.height=cwin1.Document.body.scrollHeight;
    }
    //var cwin=document.getElementById("cwin0");
    //alert(1);
    //cwin.height=cwin.Document.body.scrollHeight;*/


    }
    </script>

    </HEAD>
    <body onload="pageload()" MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <div id="newTable" align="center" style="OVERFLOW-Y: auto; Z-INDEX: 101; WIDTH: 100%; CURSOR: hand; POSITION: absolute; TOP: 10px; HEIGHT: 100%; BACKGROUND-COLOR: #ffffff">
    <!--table id="tb11" align=center style="WIDTH: 32px; CURSOR: hand; POSITION: absolute; TOP: 2px; HEIGHT: 500px"
    bgColor="#99ccff" border="1" bordercolor="#000033">
    </table-->
    </div>

    </form>
    </body>
    </HTML>
    这是全部的代码。指教一下。楼上说话注意点,
      

  9.   

    SetCwinHeight(len)--〉改为:SetCwinHeight(win)
      

  10.   

                    var win='cwin'+i;---->改为var wwin='cwin'+i
                    //alert(wwin);
                    SetCwinHeight(wwin);     
    function SetCwinHeight(len)--->SetCwinHeight(win)
            {
                //var cwin=document.getElementById("cwin");
                
                
                    
                    
                    //alert(win);
           var cwin=document.getElementById(win);----->改为ccwin=document.getElementById(win)
                    cwin.height=ccwin.Document.body.scrollHeight;你用这些试试也可以参考这个例子<body>
        <iframe marginheight="0" marginwidth="0" src="Default.aspx" frameborder="0" scrolling="no" width="100%" id="info_iframe" name="info_content" onload="change_size()"></iframe>
    </body><head>
      <script language="javascript">
        function change_size()
        {
            document.getElementById("info_iframe").style.height=info_content.document.body.scrollHeight+1+"px";
        }  
      </script>
    </head>
      

  11.   

    var   cwin=document.getElementById(win);-----> 改为ccwin=document.getElementById(win)
                                   
         cwin.height=ccwin.Document.body.scrollHeight; ----〉你的意思是不是改为:ccwin.height=ccwin.Document.body.scrollHeight;
    我试了,不行。
    另外你的下一个方法也试了,还是不行。估计应该是我的iframe是动态生成的原因。只要在代码的中间加上一个alert语句就可以顺利执行。
    比如:
                    var win='cwin'+i;
                    alert(1);        ----〉加上这一句就能执行。
                    SetCwinHeight(win);
    估计是javascript代码同步执行的原因。但是用延时功能也不能解决。
      

  12.   

    还有一个就是捉取iframe的方法
      

  13.   

    楼上有没有msn或者skype,我的msn:haiyu0117·163.com
      

  14.   

    我用:cea.height=parent.Document.body.scrollHeight; 这个可以通过,那么有没有对应的child的这样的语法。用child(或者Child).Document.body.scrollHeight;不对,是不是有别的什么单词来代替child的。
      

  15.   

    1、Document为什么要大写?
    2、25楼的问题不在于child语法,parent.document.body存在,而cwin.document.body没有装载完毕。这才是关键啊。
    3、即使你需要像25楼那样干,也不需要child,因为parent的child就是自己啊。
      

  16.   

    1、Document为什么要大写?  --->我写错了,应该小写2、25楼的问题不在于child语法,parent.document.body存在,而cwin.document.body没有装载完毕。这才是关键啊。---〉对,我也认为是这样,但是就是找不到解决办法。3、即使你需要像25楼那样干,也不需要child,因为parent的child就是自己啊。---〉我想得到该iframe所包含的窗体(src=“xx”)的高度。
    所应该是他的child。
      

  17.   

    你的代码我copy下来测试竟然是空白的
    汗!
      

  18.   

    我里边引用了xml文件里的数据,
      

  19.   

    3、即使你需要像25楼那样干,也不需要child,因为parent的child就是自己啊。---〉我想得到该iframe所包含的窗体(src=“xx”)的高度。 
    所应该是他的child。
    =================
    他的高度就是document.getElementById(yourIframeId).window.document.body.scrollHeight.
      

  20.   

    如果确实是只要alert一下就可以,不alert就不行,改造一下这个函数一定没问题的。function   SetCwinHeight(win) 

            var   cwin=document.getElementById(win); 
            if(cwin.window.document.body)cwin.height=cwin.window.document.body.scrollHeight;         else setTimeout("setCwinHeight("+win+");",1000);
    } 如果还不行,那就用下面的代码找找原因,看到底是确哪个对象:SetCwinHeight(win) 

         try{
            var   cwin=document.getElementById(win); 
            cwin.height=cwin.window.document.body.scrollHeight; } 
         }catch(e){
             var errstr = e.message;
             if(cwin)errstr += "\ncwin:"+cwin;
             else errstr += "\ncwin:null";
             if(cwin.window)errstr += "\nwindow:"+cwin.window;
             else errstr +="\nwindow:null";
             if(cwin.window.document)errstr += "\ndocument:"+cwin.window.document;
             else errstr +="\ndocument:null";
             if(cwin.window.document.body)errstr += "\nbody:"+cwin.window.document.body;
             else errstr +="\ndbody:null";
             if(cwin.window.document.body.scrollHeight)errstr += "\nheight:"+cwin.window.document.body.height;;
             else errrstr += "\nheight:null";
         }
      

  21.   

    楼上明白人,我用:setTimeout("SetCwinHeight("+win+");",1000);  延迟调用SetCwinHeight(win)方法,但是不管用。当延迟时,是不是所有代码都处于停止状态。而不是在延迟的那一秒让动态iframe运行完成。
      

  22.   

    呵呵,在catch块最后加alert(errstr);忘了。
      

  23.   

    33楼的延迟方法还是不行。
    下面的代码使了一下。SetCwinHeight(win) 

         try{
            var   cwin=document.getElementById(win); 
            cwin.height=cwin.window.document.body.scrollHeight;  //这个应该是不需要的吧
         }catch(e){
             var errstr = e.message;
             if(cwin)errstr += "\ncwin:"+cwin;
             else errstr += "\ncwin:null";
             if(cwin.window)errstr += "\nwindow:"+cwin.window;
             else errstr +="\nwindow:null";
             if(cwin.window.document)errstr += "\ndocument:"+cwin.window.document;
             else errstr +="\ndocument:null";
             if(cwin.window.document.body)errstr += "\nbody:"+cwin.window.document.body;
             else errstr +="\ndbody:null";
             if(cwin.window.document.body.scrollHeight)errstr += "\nheight:"+cwin.window.document.body.height;;
             else errrstr += "\nheight:null";
         }执行后,直接白屏。报错是<body onload="pageload()">这行,错误:请指定对象。
      

  24.   

     //这个应该是不需要的吧
    我没调试过javascript,不知怎么调试。
      

  25.   


    SetCwinHeight(win) 

         try{
            var   cwin=document.getElementById(win); 
            cwin.height=cwin.window.document.body.scrollHeight;
         }catch(e){
             var errstr = e.message;
             if(cwin)errstr += "\ncwin:"+cwin;
             else errstr += "\ncwin:null";
             if(cwin.window)errstr += "\nwindow:"+cwin.window;
             else errstr +="\nwindow:null";
             if(cwin.window.document)errstr += "\ndocument:"+cwin.window.document;
             else errstr +="\ndocument:null";
             if(cwin.window.document.body)errstr += "\nbody:"+cwin.window.document.body;
             else errstr +="\ndbody:null";
             if(cwin.window.document.body.scrollHeight)errstr += "\nheight:"+cwin.window.document.body.height;;
             else errstr += "\nheight:null";
            alert(errstr);
         }
    }
      

  26.   

    不行,如果用try{}catch(e){}语句,整个javascript都不执行。执行后,直接白屏。报错是 <body   onload="pageload()"> 这行,错误:请指定对象。
      

  27.   

    <%@ Page language="c#" Codebehind="menugoogle1.aspx.cs" AutoEventWireup="false" Inherits="t.menugoogle1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>menugoogle1</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <script type="text/javascript">

    var xmlHttp;
    var frmid = new Array();
                     
    function pageload()
    {
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET","content1.xml",true);
    xmlHttp.send(null);
    }
        
    function createXMLHttpRequest()
    {
    if(window.ActiveXObject)
    {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest)
    {
    xmlHttp = new XMLHttpRequest();
    }
    }

    function handleStateChange()
    {
    if(xmlHttp.readyState == 4)
    {
    if(xmlHttp.status == 200)
    {
    ListMenu1();
    }
    }
    }
    function ListMenu1()
    {
    var mainmenu = xmlHttp.responseXML;
    var menunode = mainmenu.getElementsByTagName("content");
    CreateRow(menunode);
    }
        
        
        //从这儿开始是动态添加控件的方法     function CreateRow(menu)
        {
    document.getElementById("newTable").innerHTML=document.getElementById("newTable").innerHTML+"<table id=tb11 align=center  border=0 width=100% cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#000099\"></table>";

    var tdData1 = document.getElementById("tb11");


    ///从xml读取的数据
    len=menu.length;
    var Title="title";
    var Link="link";
    var L_img="Limg";
    var C_img="Cimg";
    var R_img="Rimg";


    for(var i=0;i<len;i++)
    {

    content=menu[i];

    var title=getElement(content,Title);
    var link=getElement(content,Link);
    var L=getElement(content,L_img);
    var C=getElement(content,C_img);
    var R=getElement(content,R_img);
    //alert(R);
    //alert(a);
    var newRow=tdData1.insertRow(2*i); //对table添加行和列
    newRow.height=35;
    //newRow.bgcolor="#99ccff;";
    newRow.border=0;
    var cell0=newRow.insertCell(0);
    cell0.align = "right";
    //cell0.valign="top";
    //cell0.innerText=menutxt;
    //cell0.width=1;
    cell0.id=2*i;
    cell0.style.cssText="width:2%;FONT-WEIGHT: bold;color:white;";
    cell0.background=L;
    //cell0.border=0;

    var cell1=newRow.insertCell(1);
    cell1.align="center";
    //cell1.valign="top";
    //cell1.width="96%";
    //cell1.id=
    cell1.innerText=title;
    cell1.style.cssText="font-size:18px;FONT-WEIGHT: bold;";
    cell1.background=C;
    cell1.border=0;

    var cell2=newRow.insertCell(2);
    //
    cell2.align="left";
    //cell2.width=1;
    //cell2.valign="top";
    //cell1.id=
    cell2.style.cssText="width:3%;FONT-WEIGHT: bold;";
    cell2.background=R;
    cell2.border=0;

    //var Frame = document.getElementById("frame");
    //alert(Frame);
    //Frame.src=link;
    //x=this.parentElement.rowIndex;
    //var a=document.getElementById(x).innerHTML;
    //alert(a);
    //document.getElementById("frame").setAttribute("src")="http://www.baidu.com";
    var newRow=tdData1.insertRow(2*i+1);
    newRow.height=300;
    //newRow.border=0;
    var cell3=newRow.insertCell(0);
    cell3.align="center";
    cell3.valign="top";
    cell3.id=2*i+1;
    //cell3.width="80%";
    cell3.colSpan=3;
    //alert(link);
    //cell3.innerHTML='<iframe border=0 id=cwin'+i+' width=100% scrolling=no align=top src='+link+'></iframe>';
    var cea = document.createElement("iframe");//添加iframe并设置属性
    cea.id = 'cwin'+i;
    cea.Name='win'+i;
    cea.scrolling = 'no';
    cea.src = link;
    cea.width = '100%';
    //cea.height=child.document.body.scrollHeight;
    cell3.appendChild(cea);

    frmid[i]='cwin'+i;

    alert(1);

    //cea.height='100%';
    //cea.innerHeight='100%';
    //cea.height=cea.scrollHeight;
    //alert(cea);
    //var objwin=cea.contentWindow;
    //alert(objwin);
    //cea.height=parent.Document.body.scrollHeight;
    //cea.on = new Function("alert(11);");

    //alert(cea.innerHeight);
    /*cell3.style.cssText="";
    var cell4=newRow.insertCell(1);
    var cell5=newRow.insertCell(2);
    var a=document.getElementById("tb11").innerHTML;
    alert(a);
    var Frame = document.getElementById("frame");
    Frame.src=link;


    //var dd=setTimeout('SetCwinHeight('+win+');',1000);
    //alert(win);
    //alert(cell3.innerHTML);
    var n='win'+i;
    var wwin='cwin'+i;
    //alert(1);
    SetCwinHeight(wwin);*/

    }

    for(var j=0;j<frmid.length;j++)
    {
    //var wwin='cwin'+i;
    SetCwinHeight(frmid[j]);
    }

        }
        
    function getElement(menu,ele)
    {
    if(menu.getElementsByTagName(ele)[0])
    {
    if(menu.getElementsByTagName(ele)[0].firstChild)
    return menu.getElementsByTagName(ele)[0].firstChild.nodeValue;
    else
    return "";
    }
    else
    {
    return "";
    }
    }

    //自适应高度函数
    function SetCwinHeight(win)
    {
    //var cwin=document.getElementById("cwin");




    //try
    //{ alert(win);
    var cwin=document.getElementById(win);
    //if(ccwin.document.body)
    cwin.height=cwin.Document.body.scrollHeight;
    /*}
    catch(e)
    {

    var errstr = e.message;
    if(cwin)errstr += "\ncwin:"+cwin;
    else errstr += "\ncwin:null";
    if(cwin.window)errstr += "\nwindow:"+cwin.window;
    else errstr +="\nwindow:null";
    if(cwin.window.Document)errstr += "\ndocument:"+cwin.window.Document;
    else errstr +="\nDocument:null";
    if(cwin.window.window.Document.body)errstr += "\nbody:"+cwin.Document.body;
    else errstr +="\ndbody:null";
    if(cwin.Document.body.scrollHeight)errstr += "\nheight:"+cwin.Document.body.height;;
    else errstr += "\nheight:null";
    alert(errstr);
    }*/


    /*//alert(win);
    //alert(nn);


    //else
    //setTimeout("SetCwinHeight("+win+");",1000);

    /////cwin.width=cwin.Document.body.scrollWidth;

    for(var i=0;i<len;i++)
    {
    //alert(f);
    var win='cwin'+i;
    //alert(win);
    var cwin1=document.getElementById(win);
    cwin1.height=cwin1.Document.body.scrollHeight;
    }
    //var cwin=document.getElementById("cwin0");
    //alert(1);
    //cwin.height=cwin.Document.body.scrollHeight;*/

    }

    </script>
    </HEAD>
    <body onload="pageload();" MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <div id="newTable" align="center" style="OVERFLOW-Y: auto; Z-INDEX: 101; WIDTH: 100%; CURSOR: hand; POSITION: absolute; TOP: 10px; HEIGHT: 100%; BACKGROUND-COLOR: #ffffff">
    <!--table id="tb11" align=center style="WIDTH: 32px; CURSOR: hand; POSITION: absolute; TOP: 2px; HEIGHT: 500px"
    bgColor="#99ccff" border="1" bordercolor="#000033">
    </table-->
    </div>
    <FONT face="MS UI Gothic"></FONT><FONT face="MS UI Gothic"></FONT>
    </form>
    </body>
    </HTML>
      

  28.   

    改进一下:SetCwinHeight(win) 

         try{
            var   cwin=document.getElementById(win); 
            cwin.height=cwin.window.document.body.scrollHeight;
         }catch(e){
             var errstr = e.message;
             if(cwin)errstr += "\ncwin:"+cwin;
             else errstr += "\ncwin:null";
             if(cwin.window)errstr += "\nwindow:"+cwin.window;
             else errstr +="\nwindow:null";
             if(cwin.window.document)errstr += "\ndocument:"+cwin.window.document;
             else errstr +="\ndocument:null";
             if(cwin.window.document.body)errstr += "\nbody:"+cwin.window.document.body;
             else errstr +="\ndbody:null";
             if(cwin.window.document.body.scrollHeight)errstr += "\nheight:"+cwin.window.document.body.height;;
             else errstr += "\nheight:null";
             setTimeout("SetCwinHeight("+win+")",1000);
            alert(errstr);
         }
    }
     
     
     
      

  29.   

    我测试过了,是body那个对象没有。errstr的信息,body为null。
      

  30.   

    那就找找看,为什么没有body.你传下来的xml中,有一个节点叫"link",你看看是不是所有的link指向的URL的HTML中都有<body></body>元素。如果没有,加上应该就没问题了。
    还有一个办法,你可以把cea.src = link; 先去掉,改成cea.innerHTML = '<html><body></body></html>',看问题是不是消失。如果消失,说明确实是URL指定的HTML的问题。那就改好就成啦。
      

  31.   

    我的url所指向的网页都是由body元素的。我所指向的是.aspx文件,应该和html没什么区别吧。
    另外,改成cea.innerHTML   =   ' <html> <body> </body> </html> '  之后,他以后的代码,就都不执行了。