Mega Code Archive

 
Categories / JavaScript Tutorial / Window
 

Using document write() on Another Window

< html>  <head>  <title>Writing to Subwindow</title>  <script type="text/javascript">  var newWindow;  function makeNewWindow() {      newWindow = window.open("","","status,height=200,width=300");  }  function subWrite() {      if (newWindow.closed) {          makeNewWindow();      }      newWindow.focus();      var newContent = "<html><head><title>title</title></head>";      newContent += "<body bgcolor='coral'><h1>This document is brand new.</h1>";      newContent += "</body></html>";      newWindow.document.write(newContent);      newWindow.document.close();  }  </script>  </head>  <body onload="makeNewWindow()">  <form>  <input type="button" value="Write to Subwindow" onclick="subWrite()">  </form>  </body>  </html>