一. 父窗口:
<form name=form1>
<select name=parentList>
<option>请选择
</select>
</form>子窗口:
<select onchange="writeParentList(this.value)">
<option>请选择
<option value=aaa>aaa
<option value=bbb>bbb
<option value=ccc>ccc
<option value=ddd>ddd
<option value=eee>eee
</select><script language=javascript>
function writeParentList(str)
{
   if(top==window) return; //若该页没有被 frame 则跳出
   if(str=="") return;
   if(parent.document.form1.parentList)
   {
        e = parent.document.form1.parentList;
        var newOP=new Option(str, str, true, true);
        for(var i=0; i<e.options.length; i++) //不重复
           if(e.options[i].value == str) return;
        e.options[e.options.length] = newOP;
   }
}
</script>
二. opener关系:父窗口:
<form name=form1>
<select name=parentList>
<option>请选择
</select>
</form>
<script language=javascript>
function writeParentList(str)
{
   if(str=="") return;
   if(document.form1.parentList)
   {
        e = document.form1.parentList;
        var newOP=new Option(str, str, true, true);
        for(var i=0; i<e.options.length; i++) //不重复
           if(e.options[i].value == str) return;
        e.options[e.options.length] = newOP;
   }
}
</script><input type=button value=ok onclick="window.open('ttt.htm','meizz')">
子窗口:
<select onchange="if(window.name!='')opener.writeParentList(this.value)">
<option>请选择
<option value=aaa>aaa
<option value=bbb>bbb
<option value=ccc>ccc
<option value=ddd>ddd
<option value=eee>eee
</select>

解决方案 »

  1.   

    parent.opener.document.all["dhcxaaa"].options.add(new Option("456","789"));问题最主要的就是你的 new Option 生成的节点对象是本页的,而不是 parent.opener 里的对象,所以不能跨页操作,解决的办法就是:
    var opt = parent.opener.document.createElement("OPTION");
    opt.value = "456";
    opt.text  = "789";
    parent.opener.document.all["dhcxaaa"].options.add(opt);
      

  2.   

    我觉得直接写应该也可以
    没试过,只是想法,试试看
    parent.opener.document.all["dhcxaaa"].options[parent.opener.document.all["dhcxaaa"].options.length]=new Option("456","789");