Click to See Complete Forum and Search --> : open window onload and close original.


tripwater
05-09-2003, 02:53 PM
Hello, without hammering you with all the details I have a link (from a email inbox) that calls a page, this page opens and verifies you are who you say you are and allows you to continue.

Now what I need to do is have this page open my next page using a open win() so I can size the new window then close the parent or original window. Is this possible? I need to run my php code first to verify and set session variables then do the onload to open the new window and close the first (parent window).

How do I accomplish this?


If you need more of an explaination as to why or just more info in general let me know.

Thank you.

doodler
05-09-2003, 03:31 PM
If you have a window, and from that window another opens (a popup) then the original cannot be closed (by javascript) without the user allowing it (a message pops up asking the user if he/she would allow the script to close the wiindow).

The only way to close a window without this message to appear from the browser is if that window was a popup window itself.

khalidali63
05-09-2003, 03:39 PM
Originally posted by doodler
If you have a window, and from that window another opens (a popup) then the original cannot be closed (by javascript) without the user allowing it (a message pops up asking the user if he/she would allow the script to close the wiindow).
.

The above might not be true.

Check this link out.The child window it opens takes up full screen,which can be changes by changeing the width and height properties of window.

http://68.145.35.86/skills/javascripts/WindowOpenFullScreen.html

fakeName
05-09-2003, 03:43 PM
Doodler stole the words right out of my mouth. If you try to close the original window, IE (and other browsers) will alert the user:

"The Web page you are viewing is trying to close this window. Close the window now?"

This might freak some folks out.

The first pop can be closed by the second pop-up smoothly without the grouchy alert:

Though Doodler beat me to it, I had the code ready anyway, so here:



First Window HTML:

<html>
<head>
<title>First Window</title>

<script language="JavaScript" type="text/javascript">
function newWin(url,winName,features) {
if (win1 == null) {
var win1 = window.open( url, winName, features)
}
parent.close();

}

//-->
</script>
</head>
<body>
<h1>first window</h1>
<a href="win1.html" onClick="newWin('win1.html','win1','menu=no,scrollbars=no,resizable=no,width=300,height=300,top=0,left=0'); return false">Open win1.</a>
</body>
</html>



win1 HTML

<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript">
function newWin(url,winName,features) {

var win2 = window.open( url, winName, features)
win2.opener.close();

}

//-->
</script>
</head>
<body>
<h1>This is win1</h1>
<a href="win2.html" onClick="newWin('win2.html','win2','menu=no,scrollbars=no,resizable=no,width=300,height=300,top=0,left=0');" return false">Open win2. win 1 will close.</a>

</body>
</html>



win2 HTML

<html>
<head>
<title></title>

</head>
<body>
<h1>This is win2</h1>
</body>

khalidali63
05-09-2003, 03:45 PM
Originally posted by fakeName
Doodler stole the words right out of my mouth.
...........
</body>

Read my esponse above and try the link.:D
It will prove it otherwise..

doodler
05-09-2003, 03:45 PM
lol sorry. That link (http://68.145.35.86/skills/javascri...FullScreen.html) that Khalid posted has confused me!! Take a look at the source code!

khalidali63
05-09-2003, 03:47 PM
Originally posted by doodler
lol sorry. That link (http://68.145.35.86/skills/javascri...FullScreen.html) that Khalid posted has confused me!! Take a look at the source code!

The trick lies in the code thats in between the
<pre> tags,thas the one I have in the main window.

fakeName
05-09-2003, 05:00 PM
Right. Nice.

Just replace the code for first.html with:

<html>
<head>
<title>First Window</title>

<script language="JavaScript">
<!--

function closeMe(url,winName,features) {
window.opener = top;
var win1 = window.open(url,winName,features);
window.close();
}


//-->
</script>


</head>
<body onLoad="closeMe('win1.html','win1','scrollbars=no,resizable=no,left=0,top=0')">
Opens itself full screen, then opens winWin while closing itself, then closes the full screen

</body>
</html>

The only problem is: about 1/4 of the time the script crashed my browser.