parent.html:<head>
<script language="JavaScript">
  function aaa(){
    window.open("child.html"); 
  }  function clicked(sName)
  {
    alert(sName + " in child window clicked");
  }
</script>
</head>
<body>
<form name="form1">
  <input type="button" name="button1" value="button1" onClick="aaa()">
</form>
</body>
child.html:
<input type="button" name="button2" value="click" onclick="opener.clicked(this.name)">

解决方案 »

  1.   

    1.htm
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    </HEAD><BODY>
    <input type="text" name="txt" value="">
    <input type="button" name="btn" value="open" onClick="dothis();"></BODY>
    </HTML>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function dothis() {
    window.open("2.htm","_blank","");
    }
    //-->
    </SCRIPT>2.htm
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    </HEAD><BODY>
    写些东西在文本框里,然后按ok <br>
    <input type="text" name="write" value="">
    <input type="button" name="btn" value=" ok " onClick="dothis();"></BODY>
    </HTML>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function dothis() {
    opener.txt.value=write.value;
    window.close();
    }
    //-->
    </SCRIPT>
      

  2.   

    <head>
    <script language="JavaScript">
    var timer,win;
      function aaa(){
       win=window.open('about:<body><input type="button" name="button2" value="click">');    //XXX是新打开的页面的URL
       timer=setInterval("try{win.document.all.button2.onclick=myFunc;clearInterval(timer);}catch(e){}",100)
      }
      function myFunc(){
          alert("Clicked");
      }
    </script>
    </head>
    <body>
    <form name="form1">
      <input type="button" name="button1" value="button1" onClick="aaa()">
    </form>
    </body>