Use HTML to open a new window and write to it

There are times when you want to create a window with spacific information. The previous demos opened a new window with an html document. Now create a new window and fill it with HTML. Think of the HTML document that opens the new window as the parent and the window that is being created as the child. To do this define a variable that will be used to open the window and format the html. Then not only can you send information to the child window, you can also send information back to the parent window that opened it.

First create an html document that will create the child window and write html to it. The demo is an html document that creates a child with three links on it. One link will close the parent window and one link will close the child window and the third will change the satus bar on the parent window to "parent".



JavaScript on the parent window:
  1. get the name of the first link on the child window
    popupWindow.document.links[0].name;
  2. Get the name of the child window
    alert(popupWindow.name);
  3. to change the status on the child
    popupWindow.defaultStatus='stuff';
JavaScript on the child window:
  1. close the parent - notice when the child tries to close the parent, a prompt comes up to make sure you want to close the parent window.
    <a name="parentclose" href="#" onclick="parent.opener.close();return false;">
  2. close the child
    <a name="childclose" href="#" onclick="self.close();">
  3. change the name of the parent status bar to "parent"
    <a href="#" onclick="javascript:parent.opener.status=\'parent\';return false;">

click here to see the demo.