打开一个新文档,然后添加一些内容

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function winTest()
  5. {
  6. var txt1 = "This is a new window.";
  7. var txt2 = "This is a test.";
  8. win.document.open("text/html","replace");
  9. win.document.writeln(txt1);
  10. win.document.write(txt2);
  11. win.document.close();
  12. }
  13. </script>
  14. </head>
  15. <body>
  16.  
  17. <script type="text/javascript">
  18. var win=window.open('','','width=200,height=200');
  19. winTest();
  20. </script>
  21.  
  22. </body>
  23. </html>