Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers 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 developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #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
Reply With Quote
  #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 5 Times in 5 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
:::::::::::::::::::::::::::::::::
Reply With Quote
  #3 (permalink)  
Old October 16th, 2003, 02:27 AM
joefawcett's Avatar
Wrox Author
Points: 9,712, Level: 42
Points: 9,712, Level: 42 Points: 9,712, Level: 42 Points: 9,712, Level: 42
Activity: 7%
Activity: 7% Activity: 7% Activity: 7%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,066
Thanks: 1
Thanked 36 Times in 35 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
Reply With Quote
  #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 =)
Reply With Quote
  #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
Reply With Quote
  #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.

Reply With Quote
  #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;

Reply With Quote
  #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);
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 08:56 AM
Parent Page Refresh crmProg ASP.NET 2.0 Professional 0 January 15th, 2007 09: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



All times are GMT -4. The time now is 11:17 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.