向源(父)窗口写一些文本

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function openWin() {
  6. var myWindow = window.open("", "", "width=400, height=200");
  7. myWindow.opener.document.getElementById("demo").innerHTML =
  8. "已经打开一个新窗口。";
  9. }
  10. </script>
  11. </head>
  12. <body>
  13.  
  14. <button onclick="openWin()">打开 myWindow</button>
  15.  
  16. <p id="demo"></p>
  17.  
  18. </body>
  19. </html>