Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 16 people (81%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How to refresh child window when another action is done in main window with a prompt in child window

Apr 8th, 2008 18:41
ha mo, Dave Clark, Surya,


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Surya,
     The answer depends upon whether (1) the change to the parent 
window has some bearing upon the content in the child window and, 
therefore, the parent window needs to control the refresh of the child 
window -- or, (2) the child window may be refreshed independantly of 
the change made to the parent window.  The later is simple, so I 
presume that is not the question you are asking.  However, I'll answer 
that one just in case...
     Change your code in the child window, which looks similar to 
this, to add the line indicated:
prompt(...); // prompt in child window
top.opener...; // change to parent window
// new line
     If the parent window must control the refresh of the child 
window, then the child window can call a function in the parent window 
and that function uses a timer to schedule a refresh of the child 
window so that the called function can end cleanly and return control 
to the child window (albeit, temporarily until the refresh happens).
     This, in the child window:
prompt(...); // prompt in child window
top.opener...; // change to parent window
top.opener.ScheduleRefresh(); // new line
     Then, in the parent window:
var ptr1 = null; // parent window sets this when
                 // child window is first created
function ScheduleRefresh()
{
    window.setTimeout("RefreshChildWindow()", 200);
    return true;
}
function RefreshChildWindow()
{
    ptr1.location.reload(true); // one method of refresh
}
    Naturally, there are many ways to skin a cat and many ways to 
program this process.   ;-)
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com