Hi,
I have been trying to implement an ( apparently ) simple operation. I want to open a window from an existing parent window with a button, when the button is pressed the parent closes. I had tried to use the opener keyword, but when I tried to embed javascript in the new window, I got "unterminated string errors", or "object errors". Does anyone have some simple source to achieve this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE>New Window Test</TITLE>
<FORM>
<BODY>
<SCRIPT language=JavaScript>
<!--
function newWin()
{
pageContent = "<HTML><HEAD><TITLE>";
pageContent += "Close Parent Test</TITLE>";
pageContent += "</HEAD><FORM><BODY>";
pageContent += "<script langauge='JavaScript'><!-- opener.close(); //--></script>";
pageContent += "</BODY><FORM></HTML>";
cardWindow = open("","cardWin","width=450,height=350,resizable=1"
;
with (cardWindow.document)
{
open();
write(pageContent);
close();
}
}
//-->
</SCRIPT>
<INPUT type=button value="New Window" onclick=newWin();>
</BODY></FORM></HTML>
I have been trying to implement an ( apparently ) simple operation. I want to open a window from an existing parent window with a button, when the button is pressed the parent closes. I had tried to use the opener keyword, but when I tried to embed javascript in the new window, I got "unterminated string errors", or "object errors". Does anyone have some simple source to achieve this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE>New Window Test</TITLE>
<FORM>
<BODY>
<SCRIPT language=JavaScript>
<!--
function newWin()
{
pageContent = "<HTML><HEAD><TITLE>";
pageContent += "Close Parent Test</TITLE>";
pageContent += "</HEAD><FORM><BODY>";
pageContent += "<script langauge='JavaScript'><!-- opener.close(); //--></script>";
pageContent += "</BODY><FORM></HTML>";
cardWindow = open("","cardWin","width=450,height=350,resizable=1"
with (cardWindow.document)
{
open();
write(pageContent);
close();
}
}
//-->
</SCRIPT>
<INPUT type=button value="New Window" onclick=newWin();>
</BODY></FORM></HTML>