 |
Javascript How-To Ask your "How do I do this with Javascript?" questions here. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

September 22nd, 2003, 01:00 AM
|
Registered User
|
|
Join Date: Jul 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Close Parent window on opening child window
AOA All,
I m thank ful to all ppl at forum coz when ever i faced any problem .. i got solution from this forum ...
i have to web pages suppose a1.html and a2.html .. and i want that when i click on the link of a2.html from a1.html .... the second page a2.html will open in a new window ... and the parent window (a1.html) will close ..
i ll appriciate ur quick response and sample code ..
|

September 22nd, 2003, 02:57 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Do you mean like this:
a1.html
-------
Code:
<html>
<head>
<title></title>
</head>
<body>
<a href="a2.html" target="_blank">open a2.html</a>
</body>
</html>
a2.html
-------
Code:
<html>
<head>
<title></title>
</head>
<!-- this javascript closes a1.html,
but you will be prompted to confirm the closure -->
<body onload="window.opener.close();">
This is a2.html
</body>
</html>
|

September 24th, 2003, 02:09 AM
|
Registered User
|
|
Join Date: Jul 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you very much dear for your response.
i already have checked this method but actually i want all this with out conformation box ... is it possible with out confirmation message(prompt).
Thanks again for your help ...
|

September 24th, 2003, 03:02 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
You could close the child window (a2.html) without prompt, but not the main window.
|

September 24th, 2003, 11:00 AM
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Rather than having the child window close the parent, could the parent close itself when the child is launched?
Use this in a1.html:
<a href="a2.html" onclick="window.opener=self;window.close();">
|

April 9th, 2004, 12:53 PM
|
Registered User
|
|
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Would there be a way to do this without clicking anything?
|

April 9th, 2004, 01:11 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
<body onload="window.opener=top;window.open('yourpage.ht ml');window.close()">
HTH,
Snib
P2P Member
<><
|

April 9th, 2004, 04:08 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Or if you didn't want a new window to open, you could take out the window.open() part.
Snib
P2P Member
<><
|

April 11th, 2004, 12:06 PM
|
Registered User
|
|
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
is there a way to do it keeping onLoad out of the body tag?
Code:
<!--
window.onload = function() {
x=(screen.availWidth-760)/2;
y=(screen.availHeight-500)/2;
var choose=window.open('newWin1.html','gp','scrollbars=yes,resizable=no,width=760,height=500,status=no,location=no,toolbar=no, menubar=no,top='+x+',left='+y+',screenY=0,screenX=0');
}
-->
|
|
 |