<html >
<head>
<title>Untitled Document</title>
<script>
function createWindow()
{
secondwindow = window.open('','example','height=300,width=200,scrollbars=yes');
if (secondwindow != null)
{
var windowHTML= "<html><head><title>Second Window</title></head>";
windowHTML += "<body><h1 align='center'>";
windowHTML += "Another window!</h1><hr><div align='center'><form action='#' method='get'>";
windowHTML += "<input type='button' value='Set main red' onclick='window.opener.document.bgColor=\"red\";' />";
windowHTML += "<br ><input type='button' value='CLOSE' onclick='self.close();' />";
windowHTML += "</form></div></body></html>";
secondwindow.document.write(windowHTML);
secondwindow.focus();
}
}
</script>
</head>
<body>
<form action="#" method="get">
<input type="button" value="new window" onclick="createWindow();" />
<input type="button" value="set red" onclick="if (window.secondwindow) {secondwindow.document.bgColor='red';secondwindow.focus();}" />
</form>
</body>
</html>