Click to See Complete Forum and Search --> : How do you close a parent window?


bjwatts
01-28-2003, 09:22 AM
Hey,

We currently have a Web application written in ASP (that I have been recently assigned to take over) with a Log In screen that takes a user name and password. This login screen then calls itself with the submit button, validates the input, and then if validated opens a new window (with no toolbar, and sized accordingly) using JavaScript (onLoad = Immediate()). This window is really the app. I want to close the original parent window (Log In Screen). A problem is that once the user is finished with the app, they close (or when they click Log Out the child window is closed) the child window (app), and then they hit refresh on the login screen (no name or password in fields), the chid app comes back up with the previous login name and password (security problem). I think it would be easier just to close the parent window. Any ideas? Any help would GREATLY be appreciated! Thanks.

BJ Watts


**************************************************
function Immediate()
{

// Open new window
Immediate = window.open("default-2.asp","Immediate","toolbar=no,width=800,height=550,left=0,top=0,directories=no,status=no,scrollbars=yes,resizable=yes,m enubar=no");
}

khalidali63
01-28-2003, 09:42 AM
Solution to your problem is a 2 fold one.

1.
in the child window

<script type="text/javascript">
opener.close();
</script>

2.
in the parent window

<script type="text/javascript">
childWin=open('',window,'width=200,height=200');
childWin.location.href ='any.html';
if (childWin.opener == null) {childWin.opener = self;}
</script>

cheers

Khalid

khalidali63
01-28-2003, 09:50 AM
oops...a bit correction i the code a

childWin=open('','childWin','width=200,height=200');

cheers

Khalid

bjwatts
01-28-2003, 09:50 AM
Hey,

Where do I put these SCRIPT tags? In the Head Tag? Do O not use my Immediate function? This still seems to use the Microsoft's Security feature of asking the user if they want to close the window. How do I disable that?

Thanks,

BJ

khalidali63
01-28-2003, 10:18 AM
I used the code in the following manner..



<script type="text/javascript">

function openChildWindow(){
childWin=open('','childWin','width=200,height=200');
childWin.document.open();
childWin.document.write("<a href=\"javascript:top.opener.close();\">Close Parent Window</a>");
childWin.document.close();
if (childWin.opener == null) {
childWin.opener = self;
}
}

</script>
</head>

<body>
<a href="javascript:openChildWindow();">Open Child Window</a>



cheers

Khalid

bjwatts
01-28-2003, 10:28 AM
Hey,

Thanks, but this is NOT what I was looking for. Your code dictates that I must put in a link to open the child window. I want a child window to open after logging in, and then close the parent window WITHOUT have Microsoft's message asking the user if they want to close the window.

BJ