...

View Full Version : closing a window from another page



romram
04-24-2004, 08:34 PM
have a page where in this page I will pass a parameter to decide to close the window of the parent page or not, but it redirect me without closing the window..

the code used in the child page:


var finish;
parent.location="thegame.htm?finish="+1;


the code in the parent page:



<script language="javaScript">

finish=document.location.search;
finish=finish.substring(finish.lastIndexOf("=")+1);


function finishOrNot()
{

if (finish==1)
{
document.window.close();
}
}
</script>
</head>
<frameset rows="330,*" frameborder="NO" border="0" style="margin: 0" onload="finishOrNot()">
<frameset cols="*,198" frameborder="NO" >


:( :confused: :eek:

glenngv
04-26-2004, 05:37 AM
Why not directly close the parent from the child page instead of re-opening the page then eventually closing it?

parent.close()
or
top.close()

Take note that when closing parent windows (not spawned windows), a security prompt is displayed asking if the user wants to close the window or not. You cannot bypassed that prompt, you have to live with it. There is a bug on that, though, and there are exploits on it but the exploit is not recommended to be used since in the future, the bug may (will) be fixed.

romram
04-26-2004, 10:03 PM
Hi glenngv ....
I dont think that I have to live with that massege any more as this problem is solved by just two lins of code..

parent.window.opener = self;
parent.window.close();
:D ;) :D :thumbsup: ;)

liorean
04-27-2004, 01:58 AM
Which only does anything in iew. In other browsers (with the exception of Opera7, in whihc this is a known bug) the message will still appear. Note that that hack is one of those that might be fixed in the ie6.02 that comes with the new service pack for WinXP that is to be released this summer.

glenngv
04-27-2004, 02:27 AM
Hi glenngv ....
I dont think that I have to live with that massege any more as this problem is solved by just two lins of code..

parent.window.opener = self;
parent.window.close();
:D ;) :D :thumbsup: ;)

That is exactly the exploit I was talking about.
You can't rely on it as it will be fixed in future browser releases, just like liorean mentioned. :p

sarah
10-29-2005, 09:21 PM
Hi,

I am having a similar problem and not very good with javascript. I have the following pages:

Category(A)
Item 1(in category A)

What I am trying to do is the following:

When a user clicks on an item in the Category(A) page, a new window is opened and the Category(A) page is closed.

I have seen the parent.close() but not sure how to use it or where to start....

I tried putting it in the item1 page as <body onLoad=parent.close();> but this closes the item page and not the category(A) page.

Any pointers would be greatly appreciated.

Sarah



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum