Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic 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
 
Old October 20th, 2003, 04:16 PM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default closing a pop up which also goes to a new page

Hello,

I have a pop up on my site. On the pop up is a link to another standard page on my site. The problem is that it opens a new browser when the link is clicked. I have to set it to parent, because I don't want the page to open IN the pop-up window (there are not scrollbars, etc.)

I want a button which will close the pop up AND take users to that other page on my site, by replacing the main page (the page that generated the pop up to start with).

So the user is thus left with just one window open, the one they got to from the link on the pop up.

Any ideas?

 
Old October 20th, 2003, 04:34 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You direct the "parent" window by referencing window.opener and setting the location.href property. So you end up with this:

window.opener.location.href = "myNewPage.html"; //or any URL
window.close();

"parent" doesn't really work with multiple windows as it does with framesets. Once a window is opened, it's kind of on its own even though it does know who opened it.

newWindow.html
<html>
<head>
    <script language="JavaScript">
    <!--
    function goWindow(){
        window.open("popupWindow.html");
    }// end function
    //-->
</script>
</head>
<body>
    <a href="javascript:goWindow();">Open new window</a>
</body>
</html>

popupWindow.html
<html>
<head>
    <script language="JavaScript">
    <!--
    function closeWindow(){
        window.opener.location.href='http://www.google.com';
        window.close();
    }// end function
    //-->
    </script>
</head>
<body>
    <a href="javascript:closeWindow();">Go to google in "parent" window and close this one.</a>
</body>
</html>


Peter
 
Old October 21st, 2003, 04:00 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Might try:
Code:
window.opener.top.location.href = "myPage.htm";
--

Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing a Page. akhilhp ASP.NET 2.0 Basics 3 May 1st, 2007 10:03 AM
Closing page without prompt in IE7 gp_mk ASP.NET 1.0 and 1.1 Professional 2 November 22nd, 2006 10:29 AM
Redirect to new page without closing current page peter2004 ASP.NET 2.0 Basics 5 June 5th, 2006 08:49 PM
Closing ADO connections in new page darrenw SQL Server 2000 0 September 15th, 2003 11:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.