The self-closing window

Question: I am spawning a separate window for composing messages. When the user clicks the Send button, I want this window to disappear. How do I do this?

Answer: The Send button should actually be a SUBMIT button which transmits the user entries back to a PHP script on the server. This script should store the user entries in its database and also write some code back to the browser window. This code can contain a script to make the window close itself, like this:

<?
    //..database stuff
?>
     < script language="JavaScript">
	window.close()
     </script>
Note that the JavaScript security model allows this code to execute only in certain circumstances, including a window which was created by a client-side open command by another window. Otherwise, embedding this code inside an E-mail message would cause the recipient's mail program to self-destruct!