parent.txtName.value=""
parent就是父窗口对象了,直接可以引用父窗口中的所有对象。

解决方案 »

  1.   

    gfzhx(小小) :
      那是根本不行的,不过我这样写parent.document.FormName.formname3.value,也不行。不知倒底咋写?
      

  2.   

    我拭了一下不行,不过这样也不行:
    document.FormName.formname3.value
      

  3.   

    parent.document.FormName.formname3.value = "my value"
      

  4.   

    opener.document.formname.text.value=document.form2.text2.vaalue;
      

  5.   

    使用window的opener属性:以下为一个例子
    父页面:
    DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <script>
    var myWind
    functin doNew(){
       if (!myWind || myWind.closed){
         myWind = window.open("12.htm","subwindow","height=200,width=200")
       }else{
          myWind.focus()
       }
    }
    </script>
    </HEAD><BODY>
    <form name="input">
    Select a color for a new window:
    <input type="radio" name="color" value="red" checked>Red
    <input type="radio" name="color" value="yellow">Yellow
    <input type="radio" name="color" value="blue">Blue
    <input type="button" name="storage" value="Make a Window" onClick="doNew()">
    <hr>
    This field will be filled from an erntry in anthor window:
    <input type="text" name="entry" size=25>
    </form>
    </BODY>
    </HTML>
    子页面:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <script language="javascript">
    function getColor(){
       //shorten the reference
       colorButtons=self.opener.document.forms[0].color
       //see which radio button is checked
       for(var i= 0;i < colorButtons.length;i++){
         if (colorButtons[i].checked){
           return colorButtons[i].value
     }
       }
       return "white"
    }
    </script>
    </HEAD>
    <script language="javascript">
    document.write("<body bgcolor='"+getColor()+"'>")
    </script>
    <h1>This is a new Window.</h1>
    <form>
    <input type="button" value="Who's in the Main window?" onClick="alert(self.opener.docuemtn.title)"><p>
    Type text here for the main window:
    <input type="text" size=25 onChange="self.opener.document.forms[0].entry.value = this.value">
    </form>
    </BODY>
    </HTML>
    将页面保存为html文件,运行父页面即可。