to:dodo
请告诉我应该怎么写好吗?我找了很多的资料,基本上都是这么写的呀!

解决方案 »

  1.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 1</title>
    </head><body> <p><select size="8" id="txt">


    </select></p><input type="button" onclick="window.open('in.htm')" value="Open">
    </body></html>第二页
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 1</title>
    </head><script>
    function CloseOpen() {
    //opener.document.all.txt.options.add(new Option('华南地区','12'));
    opener.document.all.txt.length=opener.document.all.txt.length+1;
    opener.document.all.txt.options[opener.document.all.txt.length-1].text="华南地区";
    opener.document.all.txt.options[opener.document.all.txt.length-1].value="12";
    window.close();
    }
    </script>
    <body onunload="">
    <p><input type="button" onclick="javascript:CloseOpen();" value="close"></p>
    </body></html>
      

  2.   

    一. 父窗口:
    <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>