|
|
 |
| 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 tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |

September 22nd, 2003, 01:00 AM
|
|
Registered User
|
|
Join Date: Jul 2003
Location: Lahore, Punjab, Pakistan.
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 ..
__________________
pakdev
|

September 22nd, 2003, 02:57 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
Location: Lahore, Punjab, Pakistan.
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
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
Location: , , .
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
Location: , , .
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
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 0 Times in 0 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
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 0 Times in 0 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
Location: , , .
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');
}
-->
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |