kiss0931:办法不错?
 在请教一个问题,如何将iframe(b.htm)里的元素加入他的父窗体(a.htm),谢谢

解决方案 »

  1.   

    a.jsp:
     <input name="userName">
     <iframe src="b.jsp"></iframe>-------------------
    b.jsp (JavaScript codes):
        parent.document.all.userName.value = "中国教育改革=失败";
      

  2.   

    这个很简单了,你可以层层取出你要的参数传就可以了,如:你的父窗是frame[0],子窗是frame[1],你可以这样写求子窗的参数,frame[0].frame[1]。×××
      

  3.   

    请指教a.htm
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <script>
     function a(obj)
     {
       alert(obj.value);
     }
     function add()
     {
       for(i=0;i<window.document.frames["iframe1"].form2.length;i++)
       {
       //alert(window.document.frames["iframe1"].form2.elements(i));
         //这里总是报错,说我的参数不对,请问怎样解决?
          form1.appendChild(window.document.frames["iframe1"].form2.elements(i));
       }
     }
    </script>
    <body>
    <form id="form1" name="form1" action="a.htm">
    <table>
       <tr>
        <td><input id="info" name="info"></td>
      </tr>
      <tr>
        <td>
      <iframe id="iframe1" name="iframe1"  src="b.htm"></iframe>
    </td>
      </tr>
      <tr>
        <td>
      <input type="button"  onClick="add()" value="add">
    </td>
      </tr>
    </table>
    </form>
    </body>
    </html>b.htm
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <script language="javascript">
    function addFile(m)
    {
    var a=tablename.insertRow(tablename.rows.length);
    cell=a.insertCell(0);
    cell.innerHTML="<input type=file id=scaninfo name=scaninfo style='width:100%'>";
    cell=a.insertCell(1);
    cell.innerHTML="<input type=button name=button1 value='删除扫描件' onclick='delRow()'>";
    }
    function delRow()
    {
    tablename.deleteRow(event.srcElement.parentElement.parentElement.rowIndex);
    }
    </script>
    <body topmargin="0" rightmargin="0" leftmargin="0" bottommargin="0">
    <form id="form2" name="form2" method="post" action="a.htm">
    <table width="100%" class=sort-table id=tablename name=tablename cellSpacing=0>
       <tr>
           <td>
            <input id="scaninfo" name="scaninfo" type="file" style="width:100%" onpropertychange="add()";>
          </td>
          <td>
            <input type="button" name="button1" onClick="addFile(0)" value="添加扫描件">
          </td>  
       </tr>
    </table>
    </form>
    </body>
    </html>