rtnTB.document.all('tableid').rows.length

解决方案 »

  1.   

    这个好象没办法
    但是你可以把main中的obj传入child.htm
    在child.htm中进行判断传回
      

  2.   

    参考: http://community.csdn.net/Expert/topic/3468/3468390.xml?temp=.7623865
      

  3.   

    我做时,都是返回字符窜,或者是xml,传入参数也是。
    showModalDialog Method--------------------------------------------------------------------------------Creates a modal dialog box that displays the specified HTML document.SyntaxvReturnValue = window.showModalDialog(sURL [, vArguments][, sFeatures])ParameterssURL Required. String that specifies the URL of the document to load and display. 
    vArguments Optional. Variant that specifies the arguments to use when displaying the document. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values passed by the caller from the dialogArguments property of the window object. 
    sFeatures Optional. String that specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values: dialogHeight:iHeight  Sets the height of the dialog window (see Res for default unit of measure). 
    dialogLeft:iXPos  Sets the left position of the dialog window relative to the upper-left corner of the desktop. 
    dialogTop:iYPos  Sets the top position of the dialog window relative to the upper-left corner of the desktop. 
    dialogWidth:iWidth  Sets the width of the dialog window (see Res for default unit of measure). 
    center:{ yes | no | 1 | 0 } Specifies whether to center the dialog window within the desktop. The default is yes. 
    help:{ yes | no | 1 | 0 } Specifies whether the dialog window displays the context-sensitive Help icon. The default is yes. 
    resizable:{ yes | no | 1 | 0 } Specifies whether the dialog window has set dimensions. The default for both trusted and untrusted dialog windows is no. 
    status:{ yes | no | 1 | 0 } Specifies whether the dialog window displays a status bar. The default is yes for untrusted dialog windows and no for trusted dialog windows. 
     Return ValueVariant. Returns the value of the returnValue property as set by the window of the document specified in sURL.
      

  4.   

    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=736
      

  5.   

    把我的代码贴出来吧
    <html>
    <head>
    <title>测试主窗口</title>
    </head><script language='javascript'>
    function openWin(url)
    {
    var rtnTB = new Object();
    var flag;
    var newRow;
    var parmTB = new Object(); parmTB = document.all.mainTB;
    rtnTB = showModalDialog('child.htm', parmTB, 'dialogWidth: 480px; dialogHeight: 360px;');
    alert(rtnTB.document.all("childTB").rows.length);
    for(i=0;i<rtnTB.document.all("childTB").rows.length;i++)
    {
    flag = rtbTB.document.all("childTB").rows[i].cells[0].innerText;
    if(flag == "1")
    {
    newRow = mainTB.insertRow(mainTB.rows.length);
    c1 = newRow.insertCell(0);
    c1.innerHTML = rtbTB.document.all("childTB").rows[i].cells[1].innerText;
    }
    }
    }
    </script><body>
    <input type='button' name='openwin' onclick='openWin("child.htm");' value='openwin'>
    <table align='center' width='100%' border='1' id='mainTB'>
    <tr>
    <td>header</td>
    </tr>
    </table>
    </body>
    </html><html>
    <head>
    <title>测试子窗口</title>
    </head><script language='javascript'>
    function closeWin()
    {
    var rtnTB = new Object();
    rtnTB = document.all.childTB;
    window.returnValue = rtnTB;
    window.close();
    }
    </script><body>
    <input type='button' name='closewin' onclick='closeWin();' value='closewin'>
    <table align='center' width='100%' border='1' id='childTB'>
    <tr>
    <td>0</td>
    <td>false</td>
    </tr>
    <tr>
    <td>1</td>
    <td>true</td>
    </tr>
    <tr>
    <td>1</td>
    <td>true</td>
    </tr>
    </table><script language='javascript'>
    var parmTB = new Object();
    if (window.dialogArguments != null)
    {
    parmTB = window.dialogArguments;
    }
    alert(parmTB.document.all.mainTB.rows.length);
    </script>
    </body>
    </html>
    试了一下 ttyp(愿赌服输)的方法,child.htm返回的rtnTB.document.all("childTB").rows.length显示为'0',而主窗口传给子窗口的表格却能正确取出长度,大侠们帮研究一下该怎么改。
      

  6.   

    http://blog.csdn.net/net_lover/archive/2002/09/24/6910.aspx
      

  7.   

    <html>
    <head>
    <title>测试主窗口</title>
    </head><script language='javascript'>
    function openWin(url)
    {
    var rtnTB = new Object();
    var flag;
    var newRow;
    var parmTB = new Object(); parmTB = document.all.mainTB;
    rtnTB = showModalDialog('child.htm', window, 'dialogWidth: 480px; dialogHeight: 360px;');

    }
    </script><body>
    <input type='button' name='openwin' onclick='openWin("child.htm");' value='openwin'>
    <table align='center' width='100%' border='1' id='mainTB'>
    <tr>
    <td>header</td>
    </tr>
    </table>
    </body>
    </html>
    child.htm
    <html>
    <head>
    <title>测试子窗口</title>
    </head><script language='javascript'>
    function closeWin()
    {
    w = window.dialogArguments
    mainTB = w.document.all.mainTB
    for(i=0;i<document.all("childTB").rows.length;i++)
    {
    flag = document.all("childTB").rows[i].cells[0].innerText;
    alert(flag)
    if(flag == "1")
    {
    newRow = mainTB.insertRow(mainTB.rows.length);
    c1 = newRow.insertCell(0);
    c1.innerHTML = document.all("childTB").rows[i].cells[1].innerText;
    }
    }
    }
    </script><body>
    <input type='button' name='closewin' onclick='closeWin();' value='closewin'>
    <table align='center' width='100%' border='1' id='childTB'>
    <tr>
    <td>0</td>
    <td>false</td>
    </tr>
    <tr>
    <td>1</td>
    <td>true</td>
    </tr>
    <tr>
    <td>1</td>
    <td>true</td>
    </tr>
    </table><script language='javascript'>
    var parmTB = new Object();
    if (window.dialogArguments != null)
    {
    parmTB = window.dialogArguments;
    }
    alert(parmTB.document.all.mainTB.rows.length);
    </script>
    </body>
    </html>
      

  8.   

    因为你的子窗体已经关闭,所以必须先保存所有的子窗体中表格中的东西为ARRAY,才能被主窗体调用,如果只返回行数,window.returnValue = document.all.childTB.rows.length;
      

  9.   

    这个文章我已经看了,现在的问题是对话框传递的对象是一个怎样的结构,这个我搞不清楚。
    那我刚才的例子来说吧,我在child.htm所收到的主窗口的mainTB行数显示为1,这个是正常的。
    而子窗口传给主窗口的childTB在主窗口中就变成了0,应该是3。