Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old October 16th, 2003, 12:28 AM
Authorized User
 
Join Date: Jun 2003
Location: San Jose, CA, USA.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pop-Up Close / Refresh Parent

Ok, here's a fun one. This question is really two fold.

#1, I have a pop-up submit window. I want to user to fill out that form and hit the submit button. When they hit that submit button, it will close the pop-up window (javascript:window.close()) and refresh the parent window. (javascript:window.refresh()) So how do I tell the pop-up to refresh the parent? I can get it to refresh itself, just not refresh the parent.

#2, Imagine this: There's a textbox with a drop-down menu just below it. I want the user to type things in the textbox, then select something from the dropdown and be able to add it to the textbox automatically by clicking on a link.. Say "insert"? That link will insert the value of the dropdown at the location of their cursor. Any ideas?

Thanks in advance.

----------
~cmiller
__________________
----------
~cmiller
  #2 (permalink)  
Old October 16th, 2003, 02:24 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

For your first problem:
To change the location/refresh the parent window you can use the opener property.

This one will change the href of the parent from the pop-up.
window.opener.location.href = the_url;

The reload method will work too,
This does a hard reload (returns forms to default values)
The optional boolean conditional argument will if true make a new request of the server, if false it will attempt to pull the page from the cache.

window.opener.location.reload(true);

If you want to preserve form data (soft reload), use the history method.

window.opener.history.go(0);
'0' causes the page to reload, a negative value represents how many steps backward you'd like to go.

: )
Rich






:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
  #3 (permalink)  
Old October 16th, 2003, 02:27 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

1) If you have opened by using window.open() then:
Code:
window.opener.location.reload(true);
If you have opened by window.showModalDialog then pass self as the second parameter and use:
Code:
window.dialogArguments.location.reload(true);
Probably better to put this before the close statement.

2) If the id of your listbox is "lstCountries" and the textbox has an id of "txtTown" then in your insert tag is:
Code:
<a href="/" onclick="addListboxValue();return false;">insert</a>
and you function is:
Code:
function addListboxValue()
{
  var oLst = document.getElementById("lstCountries");
  var oTxt = document.getElementById("txtTown");
  oTxt.value += oLst.options[oLst.selectedIndex].text;
}
--

Joe
  #4 (permalink)  
Old April 14th, 2005, 02:08 AM
Registered User
 
Join Date: Apr 2005
Location: , , Malaysia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suki_icy
Default

for window.showModalDialog, we can use this also:
window.dialogArguments.location = window.dialogArguments.location;
(to avoid messagebox asking for Retry and Cancel with the message : "The page cannot be refreshed without resending the information again. Click Retry to resend the information. CLick Cancel.... ")

suki_icy =)
  #5 (permalink)  
Old June 30th, 2006, 04:47 PM
Authorized User
 
Join Date: Jun 2006
Location: Chelmsford, MA, USA.
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am facing the same probelm, can you please help me out?
Here is my code.

Following code is to open popup window:

     function OpenInstitutions(sURL)
     {
       var newwindow;
       newwindow = window.open(sURL,"Institutions","toolbar=no,locati on=no,scrollbars=yes,statusbar=no,height=600,width =870,resizable=yes");
       if (window.focus) {
        newwindow.focus()
       }
     }

Following code is to close popup and refresh parent and focus.

     function SaveSetting()
     {
       alert("Settings have been saved successfully.");
       var url = "CalInstitutions.aspx";
       opener.location.reload(true);
       //opener.history.go(0);
       opener.focus();
       self.close();
     }

The above is working, but it is showing following alert message in parent window.
"The page cannot be refreshed without resending the information again. Click Retry to resend the information. CLick Cancel.... ".

I appreciate your great help.
Thanks in advance.
ramuis78@hotmail.com
  #6 (permalink)  
Old August 25th, 2008, 07:03 AM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi I have a popup on popup close i am refreshing parent page but it is giving msgbox and when i click on retry then only my page is refreshed, is there any other way to refresh parent page.

  #7 (permalink)  
Old September 1st, 2008, 11:17 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Instead of using

opener.location.reload();

try the following

var link;
link = opener.location.href;
opener.location.href = link;

  #8 (permalink)  
Old October 6th, 2011, 05:43 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this work for me.
window.opener.location.reload(true);
setTimeout("window.close()",5);


Similar Threads
Thread Thread Starter Forum Replies Last Post
Close Child window automatically on closing parent vikas67k C# 1 August 26th, 2008 02:00 AM
Parent Page Refresh crmProg Visual Studio 2005 1 February 9th, 2007 09:56 AM
Parent Page Refresh crmProg ASP.NET 2.0 Professional 0 January 15th, 2007 10:58 PM
How to refresh parent page amolpayal Javascript How-To 1 August 2nd, 2006 05:03 AM
Refresh Parent Subform echovue Access 1 October 18th, 2005 09:59 PM





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