|
-
Mar 2nd, 2001, 08:34 AM
#1
Thread Starter
Addicted Member
Hi,
I have been trying to close a parent window when it spawns a child using the opener.close method, but have had no success. When I try to run the javascript command in the child window it reports unterminated string or runtime error. Can anyone see the problem or provide source to do this?
Source:
<!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>
-
Mar 2nd, 2001, 11:45 AM
#2
Try this code for closing your windows.
Code:
<script language="javascript">
function closeWin()
{
window.close();
};
</script>
<A HREF="javascript:closeWin();"
onMouseOver="window.status='close the Window';return true";>close Window</A>
-
Mar 2nd, 2001, 11:58 AM
#3
Thread Starter
Addicted Member
Matthew will this not just close the current window. I want a parent to open a new window, and when the new window opens the parent closes.
Thanks
Lenin.
-
Mar 16th, 2001, 01:34 PM
#4
Lively Member
This is impossible i guess...
sonia
-
Mar 19th, 2001, 06:16 AM
#5
Frenzied Member
Originally posted by harsoni
This is impossible i guess...
sonia
Don't guess!
Code:
Put the following in the child:
<script langauge="JavaScript"><!--
opener.close();
//--></script>
Although you'll need to make sure that the opener has been defined for browsers that don't have it by default, by placing the following in the parent:
<script language="JavaScript"><!--
msgWindow=open('',window,'resizable=no,width=200,height=200');
msgWindow.location.href ='apage.html';
if (msgWindow.opener == null) msgWindow.opener = self;
//--></script>
Note, that this will likely prompt the user for confirmation before closing the window.
-
Mar 19th, 2001, 04:35 PM
#6
Lively Member
Hey Mark,
That is good you showed in fact we can close the parent window from the child window...but i have a problem how do u avoid the message box that pops up???
Sonia
-
Mar 20th, 2001, 03:18 AM
#7
Frenzied Member
I had a feeling that question would be next! 
this might help:
http://developer.irt.org/script/366.htm
I haven't tried it though
(my last post came from www.irt.org as well)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|