Refresh Parent window after opening a child window and submitting

Posted on 2003-10-27
Last Modified: 2012-06-27
Hello gurus,

The situation is that I have a list page (parent page) with a list of items that the user wants to print. Once he selects all the items and clicks 'Print' on the list page, I open a child window, submit the request to the backend, change the modified timestamp for all the selected records in the database and get back the response and show it to the user. After that I want to refresh the parent window with the last modified date for all the selected items....

The problem is that the backend process might take any amount of time and I have to refresh the parent page only when I get all the data back....Can anyone suggest how I can achieve this ? I have tried putting a wait time after submitting but that doesnt seem to work...Here is the relevant code...Please help...

  if (IE5)
    _wPrint ='', PRINT_POPUP_NAME, 'scrollbars=yes,height='+PRINT_POPUP_HEIGHT+',width='+PRINT_POPUP_WIDTH+',left=100,top=100,resizable=yes,status=no,toolbar=no,directories=no,menubar=no', false);
    _wPrint ='', PRINT_POPUP_NAME, 'scrollbars=yes,height='+PRINT_POPUP_HEIGHT+',width='+PRINT_POPUP_WIDTH+',screenX=100,screenY=100,resizable=yes,status=no,toolbar=no,directories=no,menubar=no', false);
  _wPrint.document.write('<html><title>Items</title><P valign="middle" align="center" style="font-family: Arial"><B>Please wait while the page is formatted for printing...</B></P></html>'); = PRINT_POPUP_NAME;
  theForm.method = 'post';

function printDetails() {
  var f = document.pilistform;
  var numberChecked = 0;
  if (f.detaildata) {
      var itemInfo = "";
            for (var i=0; i<detailData.length; i++) {
                  if(detailData[i].checked) {
                        itemInfo += detailData[i].value + ';';
    if (itemInfo.length > 0) {
      f..value = itemInfo.substring(0, itemInfo.length - 1);
      callItemPDFPrint(f, "printitemrequest", "viewprintitemrequest");
    alert("Select One Item First");

function reload_list() {
      //Logic to reload the parent

Question by:prashanth9
LVL 25

Expert Comment

Comment Utility
in popup in body onload call function from parent window
<body onload="opener.reload_list();">

or refresh parent window
<body onload="opener.reload();">
LVL 10

Expert Comment

Comment Utility
The normal way of doing would be that the print output caries a function with it to refresh the parent window.

Are you able to extend the print output with a function for parent window refresh or is this forbidden for you?

If it is forbidden or for any other reason not possible to change the form submit response, then is the only option you have to poll the wait window in a timer interwal and observe wether some detail has changed, for example a global variable in that popup window.

Which method would you prefer: popup polling or response modify?

LVL 15

Expert Comment

Comment Utility
How about placing a target in you form and letting the server generate the new page

<form href="filetogenerateupdatedlist.php" target="nameofparetwindow">

that way the server regulates the update to happen only when the form data have been handeled.

You can give the parentpage (or any window) a name with javascript: = ""nameofparetwindow";

regards JakobA

Author Comment

Comment Utility
I have tried putting in a wait method in my parent window and depending on the number of items that get selected, I used to wait for certain number of seconds before refreshing the parent page but this proved to be unreliable....My items sometimes take very less time and sometimes very long depending on the network and database connections...I didnt understand your questions fully but if you can see the code, I call the child window from my parent window and try to refresh the parent window with logic written in it. I only need logic to make sure that I wait for as long as the child window is done processing before the parent gets refreshed...

Jakoba and Devic,

I will try implementing each of the solutions you have suggested today and see which one works. I had one question however.

How do I make sure that the parent window refreshes only after the child window gets all the content stream from the backend ? The child window might take anywhere between 1 sec and 20 seconds to get the data...I want to refresh my parent window ONLY AFTER all the processing in the child window is done.

Can anyone shed some light on this and let me know how to make sure this happens ?

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

LVL 25

Expert Comment

Comment Utility

ONLY AFTER all the processing in the window is done, come EVENT ONLOAD
LVL 16

Expert Comment

Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next four days.

EE Cleanup Volunteer

Author Comment

Comment Utility
I cannot accept any of the above answers as none of them worked for me. I implemented this logic using a different technique where I catch a Javascript Exception. Refer to this link to see how I solved the same problem :

So, no points to anyone here.

Accepted Solution

Computer101 earned 0 total points
Comment Utility
PAQed, with points refunded (125)

E-E Admin

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now