0

I opening the logout link in new tab from parent window destroying the session and redirecting the child window page to index or login page. But simultaneously i want to close parent window. How should i do it? It should work in all browser. Thanks in advance.

INV
  • 1
  • 1
  • 1
  • possible duplicate of :http://stackoverflow.com/questions/5429018/how-to-close-a-parent-window-by-pressing-a-button-on-child-window-in-javascript – Pranav Nov 09 '11 at 06:19

3 Answers3

2

You can do this:

window.opener.close();
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
  • thanks for replay i used this but its not working.. it works in IE browser but giving warning before closing the parent window. Not working with other browsers like Firefox, google chrome – INV Nov 09 '11 at 06:22
0

Use the following:

window.open('', '_self', '');
window.close();
johnnyRose
  • 7,310
  • 17
  • 40
  • 61
NidhinSPradeep
  • 1,186
  • 2
  • 14
  • 15
0

Use this on child : opener.close();

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>
Sandeep Pathak
  • 10,567
  • 8
  • 45
  • 57