Solved

Detect/address child window on parent reload - IE8 only

Posted on 2012-04-06
8
528 Views
Last Modified: 2012-06-27
I am opening a child window using the code below. From that window, I am reloading the parent document. When the parent document loads, I need to detect if there is the child window and, if so, extract a form element value to set a highlighted row in the reloaded parent document.

How do I reliably detect/address the spawned window on reload? This only needs to work for IE8 in a controlled environment.

*******************************************************************

window.onload = initPage;

function initPage() {

    document.form1.btnAddMedication.onclick = function () {
        var strURL = 'clientmedication_add.aspx?id=<%=clientid%>';
        var w = window.open(strURL, 'addMed', 'width=680,height=850,toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=yes');
    };

}
0
Comment
Question by:sailing_12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 37817482
Why not either load the parent with the parameter or call a script in the parent to reload with the parameter or set a cookie before reload???
0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 37818404
A simple solution is to use a hidden master frame to retain the context and coordinate the creation of pop-up windows and reloading of subordinate frames.
0
 
LVL 9

Expert Comment

by:experts1
ID: 37820603
This solution should work for you!

It works with a setinterval loop in the child window
which sends a reminder every 5 seconds to parent window.
And the parent window checks every 5 seconds for the
signal from the child window:

JS code for parent window:
---------------------------
  var child_exist = false;

window.onload = function() {
  childCheck = setInterval ( "check_child()", 5000 );
}
  
function check_child() {
  if(child_exist) {
    alert("child window exists");
    clearInterval(childCheck);
   }
}

Open in new window

JS code for child window:
---------------------------
window.onload = function() {
  setInterval ( "alert_parent ( )", 5000 );
}

function alert_parent ( ) {
  if(window.opener) window.opener.child_exist = true;
}

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37820625
experts1

1) window.opener will likely disappear on reload

2) please code your future setIntervals and setTimeouts like this
setInterval(alert_parent, 5000 );
since using quotes is an impliit eval.


sailing_12

To get the handle of a window opened by name, open it again;

First time:

window.open("someUrlOntheSameServer","childWindow1");

second time

var childWindow = window.open("","childWindow1");
var someField = childWindow.document.forms[0].myField.value;

but I recommend cookies
0
 
LVL 9

Expert Comment

by:experts1
ID: 37820692
Hi  mplungjan!

Been like years I havent got a feedback from you.

Thanks for the reminder.

Cheers
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37820729
I never left ;) just hit 10mio points a few weeks ago
0
 

Author Comment

by:sailing_12
ID: 37823252
Thanks for all the feedback. I am currently working the cookie approach to see if it meets my needs.
0
 

Author Closing Comment

by:sailing_12
ID: 37883433
Cookie approach seems to work for me. Thanks.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

749 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