faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 2 people (50%) answered Yes
Recently 1 of 2 people (50%) answered Yes

Entry

is there a way to determine if the parent window is still open? (in more than just ie)

Apr 7th, 2008 23:33
ha mo, Colin Fraser, aj r,


In the parent page put this code:
<script>
myWin=open('',window,'resizable=no,width=200,height=300');
myWin.location.href ='thispage.htm';
if (myWin.opener == null) myWin.opener = self;
</script>
To make sure that the parent is closed when the child opens, put this
code into the child:
<script>
if (!opener.closed) {
   opener.close() }
else {
   alert("Parent has already closed")  }
</script>
Or if you want to do something else with it :
<script> 
if (!opener.closed){ 
   opener.location.href="gohere.htm"; 
   opener.opener = top 
   opener.parent.window.close(); 
} 
</script> 
This is one solution, and it should work for what you need. From memory,
I think you will get an alert asking if it is OK to close the parent,
but I am not sure about closing the child window.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com