我改了一下left.html,虽然不是添加新行,但是原理一样的
<html>
<head>
<title></title>
</head>
<script language=javascript>
function add_right()
{
var new_document = parent.document.frame_right.document;
var new_node=new_document.createElement("div");
new_node.innerText = "test";
new_document.body.appendChild(new_node);
}
</script>
<body>
<table name="table1"  id="table1">
<tr>
<td>
<input type="button" value="test" onclick="add_right()">
left
</td>
</tr>
</table>
</body>
</html>

解决方案 »

  1.   

    the node created by the left document cannot be used by the right document, you can try this
    <html>
    <head>
    <title></title>
    </head>
    <script language=javascript>
    function remove_item(the_item)
    {
    var this_item;
    this_item=the_item.parentNode.removeChild(the_item)alert(this_item.innerHTML)
    var doc = parent.frame_right.document;
    var node = doc.createElement("tr");
    node.onclick = this_item.onclick;
    for (var i=0; i < this_item.childNodes.length;i++)
    {
      var newnode = doc.createElement("td");
      newnode.innerHTML = this_item.childNodes[i].innerHTML;
      node.appendChild(newnode);
    }
    alert(parent.frame_right.document.childNodes[0].childNodes[1].childNodes[0].childNodes[0].innerHTML)
    alert(parent.frame_right.document.childNodes[0].childNodes[1].childNodes[0].childNodes[0].lastChild.innerHTML)
    doc.childNodes[0].childNodes[1].childNodes[0].childNodes[0].appendChild(node);}
    </script>
    <body>
    <table name="table1"  id="table1">
    <tr onclick="remove_item(this)">
    <td>
    left
    </td>
    </tr>
    </table>
    </body>
    </html>
      

  2.   

    谢谢楼上
    mmkk():
    为何innerHTML赋值<td>ddddd</td>时会丢失<td>????saucer(思归):
    如何在right中实现left中的功能??
    问题是
    var doc = parent.frame_right.document;
    改为总是指向另一个iframe,怎么做??
    谢谢2位
    等候你们的信息!